-
-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preliminary LLVM 20 support #4843
base: master
Are you sure you want to change the base?
Conversation
Nice, thanks! How about becoming a member of ldc-developers, any interest? :) |
This is now required by LLVM API starting from LLVM 20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In gen_gccbuiltins.cpp
you can get away with retroactively applying const
instead of the LLVM_20_CONST
conditional.
One more change that github doesn't let me submit:
- return TableGenMain(argv[0], emit);
+ // Since LLVM-20 `records` needs to be const&
+ return TableGenMain(argv[0], [](raw_ostream &os, auto &records){
+ return emit(os, records);
+ });
#if LDC_LLVM_VER >= 2000 | ||
#define LLVM_20_CONST const | ||
#else | ||
#define LLVM_20_CONST | ||
#endif | ||
|
||
string dtype(LLVM_20_CONST Record* rec, bool readOnlyMem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if LDC_LLVM_VER >= 2000 | |
#define LLVM_20_CONST const | |
#else | |
#define LLVM_20_CONST | |
#endif | |
string dtype(LLVM_20_CONST Record* rec, bool readOnlyMem) | |
string dtype(const Record* rec, bool readOnlyMem) |
{ | ||
Init* typeInit = rec->getValueInit("VT"); | ||
LLVM_20_CONST Init* typeInit = rec->getValueInit("VT"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLVM_20_CONST Init* typeInit = rec->getValueInit("VT"); | |
auto typeInit = rec->getValueInit("VT"); |
@@ -72,7 +78,7 @@ string dtype(Record* rec, bool readOnlyMem) | |||
return ""; | |||
} | |||
|
|||
StringRef attributes(ListInit* propertyList) | |||
StringRef attributes(LLVM_20_CONST ListInit* propertyList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringRef attributes(LLVM_20_CONST ListInit* propertyList) | |
StringRef attributes(const ListInit* propertyList) |
@@ -100,13 +106,13 @@ void processRecord(raw_ostream& os, Record& rec, string arch) | |||
replace(name.begin(), name.end(), '_', '.'); | |||
name = string("llvm.") + name; | |||
|
|||
ListInit* propsList = rec.getValueAsListInit("IntrProperties"); | |||
LLVM_20_CONST ListInit* propsList = rec.getValueAsListInit("IntrProperties"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLVM_20_CONST ListInit* propsList = rec.getValueAsListInit("IntrProperties"); | |
auto propsList = rec.getValueAsListInit("IntrProperties"); |
const StringRef prop = | ||
propsList->size() ? propsList->getElementAsRecord(0)->getName() : ""; | ||
|
||
bool readOnlyMem = prop == "IntrReadArgMem" || prop == "IntrReadMem"; | ||
|
||
ListInit* paramsList = rec.getValueAsListInit("ParamTypes"); | ||
LLVM_20_CONST ListInit* paramsList = rec.getValueAsListInit("ParamTypes"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLVM_20_CONST ListInit* paramsList = rec.getValueAsListInit("ParamTypes"); | |
auto paramsList = rec.getValueAsListInit("ParamTypes"); |
@@ -117,7 +123,7 @@ void processRecord(raw_ostream& os, Record& rec, string arch) | |||
params.push_back(t); | |||
} | |||
|
|||
ListInit* retList = rec.getValueAsListInit("RetTypes"); | |||
LLVM_20_CONST ListInit* retList = rec.getValueAsListInit("RetTypes"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLVM_20_CONST ListInit* retList = rec.getValueAsListInit("RetTypes"); | |
auto retList = rec.getValueAsListInit("RetTypes"); |
@@ -145,7 +151,7 @@ void processRecord(raw_ostream& os, Record& rec, string arch) | |||
|
|||
std::string arch; | |||
|
|||
bool emit(raw_ostream& os, RecordKeeper& records) | |||
bool emit(raw_ostream& os, LLVM_20_CONST RecordKeeper& records) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool emit(raw_ostream& os, LLVM_20_CONST RecordKeeper& records) | |
bool emit(raw_ostream& os, const RecordKeeper& records) |
This pull request adds basic LLVM 20 support for LDC.
LLVM 20 changed a lot of APIs again, especially how passes are structured.