[PATCH] Add LLVMSetTargetMachineMCOption() to the C API

Tom Stellard thomas.stellard at amd.com
Wed Dec 31 08:23:00 PST 2014


Hi ributzka, echristo,

This patch adds a new function for setting MC-related TargetOptions.

http://reviews.llvm.org/D6820

Files:
  include/llvm-c/TargetMachine.h
  lib/Target/TargetMachineC.cpp

Index: include/llvm-c/TargetMachine.h
===================================================================
--- include/llvm-c/TargetMachine.h
+++ include/llvm-c/TargetMachine.h
@@ -56,6 +56,19 @@
     LLVMObjectFile
 } LLVMCodeGenFileType;
 
+typedef enum {
+  LLVMMCOptionSanitizeAddress,
+  LLVMMCOptionMCRelaxAll,
+  LLVMMCOptionMCNoExecStack,
+  LLVMMCOptionMCFatalWarnings,
+  LLVMMCOptionMCSaveTempLabels,
+  LLVMMCOptionMCUseDwarfDirectory,
+  LLVMMCOptionShowMCEncoding,
+  LLVMMCOptionShowMCInst,
+  LLVMMCOptionAsmVerbose,
+  LLVMMCOptionDwarfVersion
+} LLVMMCOption;
+
 /** Returns the first llvm::Target in the registered targets list. */
 LLVMTargetRef LLVMGetFirstTarget(void);
 /** Returns the next llvm::Target given a previous one (or null if there's none) */
@@ -122,6 +135,12 @@
 void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T,
                                       LLVMBool VerboseAsm);
 
+/** Set an MCTargetOption.
+ * \returns -1 If \p O is not a valid MCOption.  0 If \p O is valid. 1 if \p O
+ *             has been deprecated. */
+int LLVMSetTargetMachineMCOption(LLVMTargetMachineRef T, LLVMMCOption O,
+                                 unsigned V);
+
 /** Emits an asm or object file for the given module to the filename. This
   wraps several c++ only classes (among them a file stream). Returns any
   error in ErrorMessage. Use LLVMDisposeMessage to dispose the message. */
Index: lib/Target/TargetMachineC.cpp
===================================================================
--- lib/Target/TargetMachineC.cpp
+++ lib/Target/TargetMachineC.cpp
@@ -181,6 +181,47 @@
   unwrap(T)->setAsmVerbosityDefault(VerboseAsm);
 }
 
+int LLVMSetTargetMachineMCOption(LLVMTargetMachineRef T, LLVMMCOption O,
+                                 unsigned V) {
+  MCTargetOptions *Options = &unwrap(T)->Options.MCOptions;
+
+  switch(O) {
+    default: return -1;
+    case LLVMMCOptionSanitizeAddress:
+      Options->SanitizeAddress = V;
+      break;
+    case LLVMMCOptionMCRelaxAll:
+      Options->MCRelaxAll = V;
+      break;
+    case LLVMMCOptionMCNoExecStack:
+      Options->MCNoExecStack = V;
+      break;
+    case LLVMMCOptionMCFatalWarnings:
+      Options->MCFatalWarnings = V;
+      break;
+    case LLVMMCOptionMCSaveTempLabels:
+      Options->MCSaveTempLabels = V;
+      break;
+    case LLVMMCOptionMCUseDwarfDirectory:
+      Options->MCUseDwarfDirectory = V;
+      break;
+    case LLVMMCOptionShowMCEncoding:
+      Options->ShowMCEncoding = V;
+      break;
+    case LLVMMCOptionShowMCInst:
+      Options->ShowMCInst = V;
+      break;
+    case LLVMMCOptionAsmVerbose:
+      Options->AsmVerbose = V;
+      break;
+    case LLVMMCOptionDwarfVersion:
+      Options->DwarfVersion = V;
+      break;
+  }
+
+  return 0;
+}
+
 static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
   formatted_raw_ostream &OS, LLVMCodeGenFileType codegen, char **ErrorMessage) {
   TargetMachine* TM = unwrap(T);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6820.17748.patch
Type: text/x-patch
Size: 2983 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141231/c6357884/attachment.bin>


More information about the llvm-commits mailing list