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);