[llvm] [LLVM-C] Add LLVMCreateTargetMachineWithABI (PR #68406)

Sebastian Poeplau via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 30 05:42:23 PDT 2023


================
@@ -0,0 +1,54 @@
+#include "llvm-c/Core.h"
+#include "llvm-c/TargetMachine.h"
+#include "llvm/Config/llvm-config.h"
+#include "gtest/gtest.h"
+
+namespace llvm {
+
+TEST(TargetMachineCTest, TargetMachineOptions) {
+  auto *Options = LLVMCreateTargetMachineOptions();
+
+  LLVMTargetMachineOptionsSetCPU(Options, "cortex-a53");
+  LLVMTargetMachineOptionsSetFeatures(Options, "+neon");
+  LLVMTargetMachineOptionsSetABI(Options, "aapcs");
+  LLVMTargetMachineOptionsSetCodeGenOptLevel(Options, LLVMCodeGenLevelNone);
+  LLVMTargetMachineOptionsSetRelocMode(Options, LLVMRelocStatic);
+  LLVMTargetMachineOptionsSetCodeModel(Options, LLVMCodeModelKernel);
+
+  LLVMDisposeTargetMachineOptions(Options);
+}
+
+TEST(TargetMachineCTest, TargetMachineCreation) {
+  LLVMInitializeAllTargets();
+  LLVMInitializeAllTargetInfos();
+  LLVMInitializeAllTargetMCs();
+
+  // Get the default target to keep the test as generic as possible. This may
+  // not be a target for which we can generate code; in that case we give up.
+
+  auto *Triple = LLVMGetDefaultTargetTriple();
----------------
sebastianpoeplau wrote:

Good point, done.

https://github.com/llvm/llvm-project/pull/68406


More information about the llvm-commits mailing list