Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 36 additions & 35 deletions clang/utils/TableGen/MveEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ class ACLEIntrinsic {
";\n";
}

ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param);
ACLEIntrinsic(EmitterBase &ME, const Record *R, const Type *Param);
};

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -988,7 +988,7 @@ class EmitterBase {
const ScalarType *getScalarType(StringRef Name) {
return ScalarTypes[std::string(Name)].get();
}
const ScalarType *getScalarType(Record *R) {
const ScalarType *getScalarType(const Record *R) {
return getScalarType(R->getName());
}
const VectorType *getVectorType(const ScalarType *ST, unsigned Lanes) {
Expand Down Expand Up @@ -1028,7 +1028,7 @@ class EmitterBase {
// the Params list in the Tablegen record for the intrinsic), which is used
// to expand Tablegen classes like 'Vector' which mean something different in
// each member of a parametric family.
const Type *getType(Record *R, const Type *Param);
const Type *getType(const Record *R, const Type *Param);
const Type *getType(DagInit *D, const Type *Param);
const Type *getType(Init *I, const Type *Param);

Expand All @@ -1046,7 +1046,7 @@ class EmitterBase {

// Constructor and top-level functions.

EmitterBase(RecordKeeper &Records);
EmitterBase(const RecordKeeper &Records);
virtual ~EmitterBase() = default;

virtual void EmitHeader(raw_ostream &OS) = 0;
Expand All @@ -1065,7 +1065,7 @@ const Type *EmitterBase::getType(Init *I, const Type *Param) {
PrintFatalError("Could not convert this value into a type");
}

const Type *EmitterBase::getType(Record *R, const Type *Param) {
const Type *EmitterBase::getType(const Record *R, const Type *Param) {
// Pass to a subfield of any wrapper records. We don't expect more than one
// of these: immediate operands are used as plain numbers rather than as
// llvm::Value, so it's meaningless to promote their type anyway.
Expand All @@ -1088,7 +1088,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type *Param) {
// The meat of the getType system: types in the Tablegen are represented by a
// dag whose operators select sub-cases of this function.

Record *Op = cast<DefInit>(D->getOperator())->getDef();
const Record *Op = cast<DefInit>(D->getOperator())->getDef();
if (!Op->isSubClassOf("ComplexTypeOp"))
PrintFatalError(
"Expected ComplexTypeOp as dag operator in type expression");
Expand Down Expand Up @@ -1154,7 +1154,7 @@ const Type *EmitterBase::getType(DagInit *D, const Type *Param) {

Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
const Type *Param) {
Record *Op = cast<DefInit>(D->getOperator())->getDef();
const Record *Op = cast<DefInit>(D->getOperator())->getDef();

if (Op->getName() == "seq") {
Result::Scope SubScope = Scope;
Expand Down Expand Up @@ -1211,7 +1211,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
} else if (Op->getName() == "unsignedflag") {
if (D->getNumArgs() != 1)
PrintFatalError("unsignedflag should have exactly one argument");
Record *TypeRec = cast<DefInit>(D->getArg(0))->getDef();
const Record *TypeRec = cast<DefInit>(D->getArg(0))->getDef();
if (!TypeRec->isSubClassOf("Type"))
PrintFatalError("unsignedflag's argument should be a type");
if (const auto *ST = dyn_cast<ScalarType>(getType(TypeRec, Param))) {
Expand All @@ -1223,7 +1223,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
} else if (Op->getName() == "bitsize") {
if (D->getNumArgs() != 1)
PrintFatalError("bitsize should have exactly one argument");
Record *TypeRec = cast<DefInit>(D->getArg(0))->getDef();
const Record *TypeRec = cast<DefInit>(D->getArg(0))->getDef();
if (!TypeRec->isSubClassOf("Type"))
PrintFatalError("bitsize's argument should be a type");
if (const auto *ST = dyn_cast<ScalarType>(getType(TypeRec, Param))) {
Expand All @@ -1239,7 +1239,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
if (Op->isSubClassOf("IRBuilderBase")) {
std::set<unsigned> AddressArgs;
std::map<unsigned, std::string> IntegerArgs;
for (Record *sp : Op->getValueAsListOfDefs("special_params")) {
for (const Record *sp : Op->getValueAsListOfDefs("special_params")) {
unsigned Index = sp->getValueAsInt("index");
if (sp->isSubClassOf("IRBuilderAddrParam")) {
AddressArgs.insert(Index);
Expand All @@ -1251,7 +1251,7 @@ Result::Ptr EmitterBase::getCodeForDag(DagInit *D, const Result::Scope &Scope,
Args, AddressArgs, IntegerArgs);
} else if (Op->isSubClassOf("IRIntBase")) {
std::vector<const Type *> ParamTypes;
for (Record *RParam : Op->getValueAsListOfDefs("params"))
for (const Record *RParam : Op->getValueAsListOfDefs("params"))
ParamTypes.push_back(getType(RParam, Param));
std::string IntName = std::string(Op->getValueAsString("intname"));
if (Op->getValueAsBit("appendKind"))
Expand Down Expand Up @@ -1294,7 +1294,7 @@ Result::Ptr EmitterBase::getCodeForDagArg(DagInit *D, unsigned ArgNum,
return getCodeForDag(DI, Scope, Param);

if (auto *DI = dyn_cast<DefInit>(Arg)) {
Record *Rec = DI->getDef();
const Record *Rec = DI->getDef();
if (Rec->isSubClassOf("Type")) {
const Type *T = getType(Rec, Param);
return std::make_shared<TypeResult>(T);
Expand Down Expand Up @@ -1328,7 +1328,8 @@ Result::Ptr EmitterBase::getCodeForArg(unsigned ArgNum, const Type *ArgType,
return V;
}

ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, const Record *R,
const Type *Param)
: ReturnType(ME.getType(R->getValueAsDef("ret"), Param)) {
// Derive the intrinsic's full name, by taking the name of the
// Tablegen record (or override) and appending the suffix from its
Expand All @@ -1346,7 +1347,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
// full name as specified by its 'pnt' member ('polymorphic name type'),
// which indicates how many type suffixes to remove, and any other piece of
// the name that should be removed.
Record *PolymorphicNameType = R->getValueAsDef("pnt");
const Record *PolymorphicNameType = R->getValueAsDef("pnt");
SmallVector<StringRef, 8> NameParts;
StringRef(FullName).split(NameParts, '_');
for (unsigned i = 0, e = PolymorphicNameType->getValueAsInt(
Expand Down Expand Up @@ -1393,11 +1394,11 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
// what values it can take, for Sema checking.
bool Immediate = false;
if (auto TypeDI = dyn_cast<DefInit>(TypeInit)) {
Record *TypeRec = TypeDI->getDef();
const Record *TypeRec = TypeDI->getDef();
if (TypeRec->isSubClassOf("Immediate")) {
Immediate = true;

Record *Bounds = TypeRec->getValueAsDef("bounds");
const Record *Bounds = TypeRec->getValueAsDef("bounds");
ImmediateArg &IA = ImmediateArgs[i];
if (Bounds->isSubClassOf("IB_ConstRange")) {
IA.boundsType = ImmediateArg::BoundsType::ExplicitRange;
Expand Down Expand Up @@ -1440,7 +1441,7 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
// Finally, go through the codegen dag and translate it into a Result object
// (with an arbitrary DAG of depended-on Results hanging off it).
DagInit *CodeDag = R->getValueAsDag("codegen");
Record *MainOp = cast<DefInit>(CodeDag->getOperator())->getDef();
const Record *MainOp = cast<DefInit>(CodeDag->getOperator())->getDef();
if (MainOp->isSubClassOf("CustomCodegen")) {
// Or, if it's the special case of CustomCodegen, just accumulate
// a list of parameters we're going to assign to variables before
Expand All @@ -1464,21 +1465,21 @@ ACLEIntrinsic::ACLEIntrinsic(EmitterBase &ME, Record *R, const Type *Param)
}
}

EmitterBase::EmitterBase(RecordKeeper &Records) {
EmitterBase::EmitterBase(const RecordKeeper &Records) {
// Construct the whole EmitterBase.

// First, look up all the instances of PrimitiveType. This gives us the list
// of vector typedefs we have to put in arm_mve.h, and also allows us to
// collect all the useful ScalarType instances into a big list so that we can
// use it for operations such as 'find the unsigned version of this signed
// integer type'.
for (Record *R : Records.getAllDerivedDefinitions("PrimitiveType"))
for (const Record *R : Records.getAllDerivedDefinitions("PrimitiveType"))
ScalarTypes[std::string(R->getName())] = std::make_unique<ScalarType>(R);

// Now go through the instances of Intrinsic, and for each one, iterate
// through its list of type parameters making an ACLEIntrinsic for each one.
for (Record *R : Records.getAllDerivedDefinitions("Intrinsic")) {
for (Record *RParam : R->getValueAsListOfDefs("params")) {
for (const Record *R : Records.getAllDerivedDefinitions("Intrinsic")) {
for (const Record *RParam : R->getValueAsListOfDefs("params")) {
const Type *Param = getType(RParam, getVoidType());
auto Intrinsic = std::make_unique<ACLEIntrinsic>(*this, R, Param);
ACLEIntrinsics[Intrinsic->fullName()] = std::move(Intrinsic);
Expand Down Expand Up @@ -1752,7 +1753,7 @@ void EmitterBase::GroupSemaChecks(

class MveEmitter : public EmitterBase {
public:
MveEmitter(RecordKeeper &Records) : EmitterBase(Records){};
MveEmitter(const RecordKeeper &Records) : EmitterBase(Records) {}
void EmitHeader(raw_ostream &OS) override;
void EmitBuiltinDef(raw_ostream &OS) override;
void EmitBuiltinSema(raw_ostream &OS) override;
Expand Down Expand Up @@ -2010,14 +2011,14 @@ class CdeEmitter : public EmitterBase {
std::map<StringRef, FunctionMacro> FunctionMacros;

public:
CdeEmitter(RecordKeeper &Records);
CdeEmitter(const RecordKeeper &Records);
void EmitHeader(raw_ostream &OS) override;
void EmitBuiltinDef(raw_ostream &OS) override;
void EmitBuiltinSema(raw_ostream &OS) override;
};

CdeEmitter::CdeEmitter(RecordKeeper &Records) : EmitterBase(Records) {
for (Record *R : Records.getAllDerivedDefinitions("FunctionMacro"))
CdeEmitter::CdeEmitter(const RecordKeeper &Records) : EmitterBase(Records) {
for (const Record *R : Records.getAllDerivedDefinitions("FunctionMacro"))
FunctionMacros.emplace(R->getName(), FunctionMacro(*R));
}

Expand Down Expand Up @@ -2179,45 +2180,45 @@ namespace clang {

// MVE

void EmitMveHeader(RecordKeeper &Records, raw_ostream &OS) {
void EmitMveHeader(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitHeader(OS);
}

void EmitMveBuiltinDef(RecordKeeper &Records, raw_ostream &OS) {
void EmitMveBuiltinDef(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinDef(OS);
}

void EmitMveBuiltinSema(RecordKeeper &Records, raw_ostream &OS) {
void EmitMveBuiltinSema(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinSema(OS);
}

void EmitMveBuiltinCG(RecordKeeper &Records, raw_ostream &OS) {
void EmitMveBuiltinCG(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinCG(OS);
}

void EmitMveBuiltinAliases(RecordKeeper &Records, raw_ostream &OS) {
void EmitMveBuiltinAliases(const RecordKeeper &Records, raw_ostream &OS) {
MveEmitter(Records).EmitBuiltinAliases(OS);
}

// CDE

void EmitCdeHeader(RecordKeeper &Records, raw_ostream &OS) {
void EmitCdeHeader(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitHeader(OS);
}

void EmitCdeBuiltinDef(RecordKeeper &Records, raw_ostream &OS) {
void EmitCdeBuiltinDef(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinDef(OS);
}

void EmitCdeBuiltinSema(RecordKeeper &Records, raw_ostream &OS) {
void EmitCdeBuiltinSema(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinSema(OS);
}

void EmitCdeBuiltinCG(RecordKeeper &Records, raw_ostream &OS) {
void EmitCdeBuiltinCG(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinCG(OS);
}

void EmitCdeBuiltinAliases(RecordKeeper &Records, raw_ostream &OS) {
void EmitCdeBuiltinAliases(const RecordKeeper &Records, raw_ostream &OS) {
CdeEmitter(Records).EmitBuiltinAliases(OS);
}

Expand Down
26 changes: 16 additions & 10 deletions clang/utils/TableGen/TableGenBackends.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,28 @@ void EmitSmeRangeChecks(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitSmeStreamingAttrs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitSmeBuiltinZAState(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);

void EmitMveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitMveBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitMveBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitMveBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitMveBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitMveHeader(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitMveBuiltinDef(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitMveBuiltinSema(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitMveBuiltinCG(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitMveBuiltinAliases(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);

void EmitRVVHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitRVVBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitRVVBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitRVVBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);

void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitCdeBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitCdeBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitCdeBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitCdeHeader(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitCdeBuiltinDef(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitCdeBuiltinSema(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
void EmitCdeBuiltinCG(const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
void EmitCdeBuiltinAliases(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);

void EmitClangAttrDocs(const llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
Expand Down