[llvm] [LLVM-C] Add LLVMCreateTargetMachineWithABI (PR #68406)
Sebastian Poeplau via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 25 06:55:08 PDT 2023
================
@@ -96,56 +115,114 @@ LLVMBool LLVMTargetHasAsmBackend(LLVMTargetRef T) {
return unwrap(T)->hasMCAsmBackend();
}
-LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T,
- const char *Triple, const char *CPU, const char *Features,
- LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
- LLVMCodeModel CodeModel) {
- std::optional<Reloc::Model> RM;
- switch (Reloc){
- case LLVMRelocStatic:
- RM = Reloc::Static;
- break;
- case LLVMRelocPIC:
- RM = Reloc::PIC_;
- break;
- case LLVMRelocDynamicNoPic:
- RM = Reloc::DynamicNoPIC;
- break;
- case LLVMRelocROPI:
- RM = Reloc::ROPI;
- break;
- case LLVMRelocRWPI:
- RM = Reloc::RWPI;
- break;
- case LLVMRelocROPI_RWPI:
- RM = Reloc::ROPI_RWPI;
- break;
- default:
- break;
- }
+LLVMTargetMachineOptionsRef LLVMCreateTargetMachineOptions(void) {
+ return wrap(new LLVMTargetMachineOptions());
+}
- bool JIT;
- std::optional<CodeModel::Model> CM = unwrap(CodeModel, JIT);
+void LLVMDisposeTargetMachineOptions(LLVMTargetMachineOptionsRef Options) {
+ delete unwrap(Options);
+}
+
+void LLVMTargetMachineOptionsSetCPU(LLVMTargetMachineOptionsRef Options,
+ const char *CPU) {
+ unwrap(Options)->CPU = CPU;
+}
+
+void LLVMTargetMachineOptionsSetFeatures(LLVMTargetMachineOptionsRef Options,
+ const char *Features) {
+ unwrap(Options)->Features = Features;
+}
+void LLVMTargetMachineOptionsSetABI(LLVMTargetMachineOptionsRef Options,
+ const char *ABI) {
+ unwrap(Options)->ABI = ABI;
+}
+
+void LLVMTargetMachineOptionsSetCodeGenOptLevel(
+ LLVMTargetMachineOptionsRef Options, LLVMCodeGenOptLevel Level) {
CodeGenOptLevel OL;
+
switch (Level) {
- case LLVMCodeGenLevelNone:
- OL = CodeGenOptLevel::None;
- break;
- case LLVMCodeGenLevelLess:
- OL = CodeGenOptLevel::Less;
- break;
- case LLVMCodeGenLevelAggressive:
- OL = CodeGenOptLevel::Aggressive;
- break;
- default:
- OL = CodeGenOptLevel::Default;
- break;
+ case LLVMCodeGenLevelNone:
+ OL = CodeGenOptLevel::None;
+ break;
+ case LLVMCodeGenLevelLess:
+ OL = CodeGenOptLevel::Less;
+ break;
+ case LLVMCodeGenLevelAggressive:
+ OL = CodeGenOptLevel::Aggressive;
+ break;
+ default:
----------------
sebastianpoeplau wrote:
The default was actually a way to handle `LLVMCodeGenLevelDefault`; I've handled that value explicitly and left the switch statement without a default, so that the compiler now warns if the enum is extended. Same for the translation of the `LLVMRelocMode`.
https://github.com/llvm/llvm-project/pull/68406
More information about the llvm-commits
mailing list