aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/utils/TableGen/MveEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/utils/TableGen/MveEmitter.cpp')
-rw-r--r--contrib/llvm-project/clang/utils/TableGen/MveEmitter.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/contrib/llvm-project/clang/utils/TableGen/MveEmitter.cpp b/contrib/llvm-project/clang/utils/TableGen/MveEmitter.cpp
index 091af2dc52a1..496cb10d14f2 100644
--- a/contrib/llvm-project/clang/utils/TableGen/MveEmitter.cpp
+++ b/contrib/llvm-project/clang/utils/TableGen/MveEmitter.cpp
@@ -212,6 +212,7 @@ public:
std::string llvmName() const override {
return "llvm::PointerType::getUnqual(" + Pointee->llvmName() + ")";
}
+ const Type *getPointeeType() const { return Pointee; }
static bool classof(const Type *T) {
return T->typeKind() == TypeKind::Pointer;
@@ -349,13 +350,8 @@ public:
bool requiresFloat() const override { return false; };
bool requiresMVE() const override { return true; }
std::string llvmName() const override {
- // Use <4 x i1> instead of <2 x i1> for two-lane vector types. See
- // the comment in llvm/lib/Target/ARM/ARMInstrMVE.td for further
- // explanation.
- unsigned ModifiedLanes = (Lanes == 2 ? 4 : Lanes);
-
- return "llvm::FixedVectorType::get(Builder.getInt1Ty(), " +
- utostr(ModifiedLanes) + ")";
+ return "llvm::FixedVectorType::get(Builder.getInt1Ty(), " + utostr(Lanes) +
+ ")";
}
static bool classof(const Type *T) {
@@ -707,12 +703,14 @@ public:
class AddressResult : public Result {
public:
Ptr Arg;
+ const Type *Ty;
unsigned Align;
- AddressResult(Ptr Arg, unsigned Align) : Arg(Arg), Align(Align) {}
+ AddressResult(Ptr Arg, const Type *Ty, unsigned Align)
+ : Arg(Arg), Ty(Ty), Align(Align) {}
void genCode(raw_ostream &OS,
CodeGenParamAllocator &ParamAlloc) const override {
- OS << "Address(" << Arg->varname() << ", CharUnits::fromQuantity("
- << Align << "))";
+ OS << "Address(" << Arg->varname() << ", " << Ty->llvmName()
+ << ", CharUnits::fromQuantity(" << Align << "))";
}
std::string typeName() const override {
return "Address";
@@ -884,7 +882,7 @@ public:
} else if (V->varnameUsed()) {
std::string Type = V->typeName();
OS << V->typeName();
- if (!StringRef(Type).endswith("*"))
+ if (!StringRef(Type).ends_with("*"))
OS << " ";
OS << V->varname() << " = ";
}
@@ -898,7 +896,7 @@ public:
llvm::APInt i = iOrig.trunc(64);
SmallString<40> s;
i.toString(s, 16, true, true);
- return std::string(s.str());
+ return std::string(s);
}
std::string genSema() const {
@@ -1194,13 +1192,21 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
if (D->getNumArgs() != 2)
PrintFatalError("'address' should have two arguments");
Result::Ptr Arg = getCodeForDagArg(D, 0, Scope, Param);
+
+ const Type *Ty = nullptr;
+ if (auto *DI = dyn_cast<DagInit>(D->getArg(0)))
+ if (auto *PTy = dyn_cast<PointerType>(getType(DI->getOperator(), Param)))
+ Ty = PTy->getPointeeType();
+ if (!Ty)
+ PrintFatalError("'address' pointer argument should be a pointer");
+
unsigned Alignment;
if (auto *II = dyn_cast<IntInit>(D->getArg(1))) {
Alignment = II->getValue();
} else {
PrintFatalError("'address' alignment argument should be an integer");
}
- return std::make_shared<AddressResult>(Arg, Alignment);
+ return std::make_shared<AddressResult>(Arg, Ty, Alignment);
} else if (Op->getName() == "unsignedflag") {
if (D->getNumArgs() != 1)
PrintFatalError("unsignedflag should have exactly one argument");
@@ -1494,8 +1500,7 @@ protected:
class raw_self_contained_string_ostream : private string_holder,
public raw_string_ostream {
public:
- raw_self_contained_string_ostream()
- : string_holder(), raw_string_ostream(S) {}
+ raw_self_contained_string_ostream() : raw_string_ostream(S) {}
};
const char LLVMLicenseHeader[] =
@@ -1675,7 +1680,7 @@ void EmitterBase::EmitBuiltinCG(raw_ostream &OS) {
for (size_t i = 0, e = MG.ParamTypes.size(); i < e; ++i) {
StringRef Type = MG.ParamTypes[i];
OS << " " << Type;
- if (!Type.endswith("*"))
+ if (!Type.ends_with("*"))
OS << " ";
OS << " Param" << utostr(i) << ";\n";
}
@@ -1828,7 +1833,7 @@ void MveEmitter::EmitHeader(raw_ostream &OS) {
// prototype.
std::string RetTypeName = Int.returnType()->cName();
- if (!StringRef(RetTypeName).endswith("*"))
+ if (!StringRef(RetTypeName).ends_with("*"))
RetTypeName += " ";
std::vector<std::string> ArgTypeNames;
@@ -1941,8 +1946,8 @@ void MveEmitter::EmitHeader(raw_ostream &OS) {
void MveEmitter::EmitBuiltinDef(raw_ostream &OS) {
for (const auto &kv : ACLEIntrinsics) {
const ACLEIntrinsic &Int = *kv.second;
- OS << "TARGET_HEADER_BUILTIN(__builtin_arm_mve_" << Int.fullName()
- << ", \"\", \"n\", \"arm_mve.h\", ALL_LANGUAGES, \"\")\n";
+ OS << "BUILTIN(__builtin_arm_mve_" << Int.fullName()
+ << ", \"\", \"n\")\n";
}
std::set<std::string> ShortNamesSeen;
@@ -2073,7 +2078,7 @@ void CdeEmitter::EmitHeader(raw_ostream &OS) {
// Make strings for the types involved in the function's
// prototype.
std::string RetTypeName = Int.returnType()->cName();
- if (!StringRef(RetTypeName).endswith("*"))
+ if (!StringRef(RetTypeName).ends_with("*"))
RetTypeName += " ";
std::vector<std::string> ArgTypeNames;
@@ -2151,8 +2156,8 @@ void CdeEmitter::EmitBuiltinDef(raw_ostream &OS) {
if (kv.second->headerOnly())
continue;
const ACLEIntrinsic &Int = *kv.second;
- OS << "TARGET_HEADER_BUILTIN(__builtin_arm_cde_" << Int.fullName()
- << ", \"\", \"ncU\", \"arm_cde.h\", ALL_LANGUAGES, \"\")\n";
+ OS << "BUILTIN(__builtin_arm_cde_" << Int.fullName()
+ << ", \"\", \"ncU\")\n";
}
}