[Offload][NFC] Use a sensible order for APIGen (#154518)
The order entries in the tablegen API files are iterated is not the order they appear in the file. To avoid any issues with the order changing in future, we now generate all definitions of a certain class before class that can use them. This is a NFC; the definitions don't actually change, just the order they exist in in the OffloadAPI.h header.
This commit is contained in:
parent
273ca1f77b
commit
2e74cc6c04
@ -127,7 +127,7 @@ def : Struct {
|
|||||||
def : Typedef {
|
def : Typedef {
|
||||||
let name = "ol_result_t";
|
let name = "ol_result_t";
|
||||||
let desc = "Result type returned by all entry points.";
|
let desc = "Result type returned by all entry points.";
|
||||||
let value = "const ol_error_struct_t*";
|
let value = "const struct ol_error_struct_t*";
|
||||||
}
|
}
|
||||||
|
|
||||||
def : Macro {
|
def : Macro {
|
||||||
|
@ -226,31 +226,23 @@ OL_APIEXPORT ol_result_t OL_APICALL {0}WithCodeLoc(
|
|||||||
void EmitOffloadAPI(const RecordKeeper &Records, raw_ostream &OS) {
|
void EmitOffloadAPI(const RecordKeeper &Records, raw_ostream &OS) {
|
||||||
OS << GenericHeader;
|
OS << GenericHeader;
|
||||||
OS << FileHeader;
|
OS << FileHeader;
|
||||||
// Generate main API definitions
|
|
||||||
for (auto *R : Records.getAllDerivedDefinitions("APIObject")) {
|
|
||||||
if (R->isSubClassOf("Macro")) {
|
|
||||||
ProcessMacro(MacroRec{R}, OS);
|
|
||||||
} else if (R->isSubClassOf("Typedef")) {
|
|
||||||
ProcessTypedef(TypedefRec{R}, OS);
|
|
||||||
} else if (R->isSubClassOf("Handle")) {
|
|
||||||
ProcessHandle(HandleRec{R}, OS);
|
|
||||||
} else if (R->isSubClassOf("Function")) {
|
|
||||||
ProcessFunction(FunctionRec{R}, OS);
|
|
||||||
} else if (R->isSubClassOf("Enum")) {
|
|
||||||
ProcessEnum(EnumRec{R}, OS);
|
|
||||||
} else if (R->isSubClassOf("Struct")) {
|
|
||||||
ProcessStruct(StructRec{R}, OS);
|
|
||||||
} else if (R->isSubClassOf("FptrTypedef")) {
|
|
||||||
ProcessFptrTypedef(FptrTypedefRec{R}, OS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate auxiliary definitions (func param structs etc)
|
// Generate main API definitions
|
||||||
|
for (auto *R : Records.getAllDerivedDefinitions("Macro"))
|
||||||
|
ProcessMacro(MacroRec{R}, OS);
|
||||||
|
for (auto *R : Records.getAllDerivedDefinitions("Handle"))
|
||||||
|
ProcessHandle(HandleRec{R}, OS);
|
||||||
|
for (auto *R : Records.getAllDerivedDefinitions("Enum"))
|
||||||
|
ProcessEnum(EnumRec{R}, OS);
|
||||||
|
for (auto *R : Records.getAllDerivedDefinitions("Typedef"))
|
||||||
|
ProcessTypedef(TypedefRec{R}, OS);
|
||||||
|
for (auto *R : Records.getAllDerivedDefinitions("FptrTypedef"))
|
||||||
|
ProcessFptrTypedef(FptrTypedefRec{R}, OS);
|
||||||
|
for (auto *R : Records.getAllDerivedDefinitions("Struct"))
|
||||||
|
ProcessStruct(StructRec{R}, OS);
|
||||||
for (auto *R : Records.getAllDerivedDefinitions("Function")) {
|
for (auto *R : Records.getAllDerivedDefinitions("Function")) {
|
||||||
ProcessFuncParamStruct(FunctionRec{R}, OS);
|
ProcessFuncParamStruct(FunctionRec{R}, OS);
|
||||||
}
|
ProcessFunction(FunctionRec{R}, OS);
|
||||||
|
|
||||||
for (auto *R : Records.getAllDerivedDefinitions("Function")) {
|
|
||||||
ProcessFuncWithCodeLocVariant(FunctionRec{R}, OS);
|
ProcessFuncWithCodeLocVariant(FunctionRec{R}, OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user