diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 5.1.1 (2017-12-26)
+
+* Fix argument order in `LLVM_Hs_CreateTargetMachine`. This affects `withTargetMachine` and `withHostTargetMachine`.
+* Add support for `MCTargetOptions`.
+
 ## 5.1.0 (2017-10-12)
 
 ### Bugfixes
diff --git a/llvm-hs.cabal b/llvm-hs.cabal
--- a/llvm-hs.cabal
+++ b/llvm-hs.cabal
@@ -1,5 +1,5 @@
 name: llvm-hs
-version: 5.1.0
+version: 5.1.1
 license: BSD3
 license-file: LICENSE
 author: Anthony Cowley, Stephen Diehl, Moritz Kiefer <moritz.kiefer@purelyfunctional.org>, Benjamin S. Scarlet
diff --git a/src/LLVM/Internal/FFI/LLVMCTypes.hsc b/src/LLVM/Internal/FFI/LLVMCTypes.hsc
--- a/src/LLVM/Internal/FFI/LLVMCTypes.hsc
+++ b/src/LLVM/Internal/FFI/LLVMCTypes.hsc
@@ -250,6 +250,11 @@
 #define TOF_Rec(n) { #n, LLVM_Hs_TargetOptionFlag_ ## n },
 #{inject TARGET_OPTION_FLAG, TargetOptionFlag, TargetOptionFlag, targetOptionFlag, TOF_Rec}
 
+newtype MCTargetOptionFlag = MCTargetOptionFlag CUInt
+  deriving (Eq, Read, Show, Typeable, Data, Generic)
+#define MCTOF_Rec(n) { #n, LLVM_Hs_MCTargetOptionFlag_ ## n },
+#{inject MC_TARGET_OPTION_FLAG, MCTargetOptionFlag, MCTargetOptionFlag, mcTargetOptionFlag, MCTOF_Rec}
+
 newtype DebugCompressionType = DebugCompressionType CUInt
   deriving (Eq, Read, Show, Typeable, Data, Generic)
 #define DCT_Rec(n) { #n, LLVM_Hs_DebugCompressionType_ ## n },
diff --git a/src/LLVM/Internal/FFI/Target.h b/src/LLVM/Internal/FFI/Target.h
--- a/src/LLVM/Internal/FFI/Target.h
+++ b/src/LLVM/Internal/FFI/Target.h
@@ -1,58 +1,80 @@
 #ifndef __LLVM_INTERNAL_FFI__TARGET__H__
 #define __LLVM_INTERNAL_FFI__TARGET__H__
 
-#define LLVM_HS_FOR_EACH_RELOC_MODEL(macro)	\
-	macro(Default, Default)													\
-	macro(Static, Static)														\
-	macro(PIC, PIC_)																\
-	macro(DynamicNoPic, DynamicNoPIC)
+#define LLVM_HS_FOR_EACH_RELOC_MODEL(macro) \
+  macro(Default, Default)                         \
+  macro(Static, Static)                           \
+  macro(PIC, PIC_)                                \
+  macro(DynamicNoPic, DynamicNoPIC)
 
 #define LLVM_HS_FOR_EACH_CODE_MODEL(macro) \
-	macro(Default)																\
-	macro(JITDefault)															\
-	macro(Small)																	\
-	macro(Kernel)																	\
-	macro(Medium)																	\
-	macro(Large)
+  macro(Default)                                \
+  macro(JITDefault)                             \
+  macro(Small)                                  \
+  macro(Kernel)                                 \
+  macro(Medium)                                 \
+  macro(Large)
 
 #define LLVM_HS_FOR_EACH_CODE_GEN_OPT_LEVEL(macro) \
-	macro(None)																						\
-	macro(Less)																						\
-	macro(Default)																				\
-	macro(Aggressive)
+  macro(None)                                           \
+  macro(Less)                                           \
+  macro(Default)                                        \
+  macro(Aggressive)
 
-#define LLVM_HS_FOR_EACH_CODE_GEN_FILE_TYPE(macro)	\
-	macro(Assembly)                                       \
-	macro(Object)
+#define LLVM_HS_FOR_EACH_CODE_GEN_FILE_TYPE(macro)  \
+  macro(Assembly)                                       \
+  macro(Object)
 
-#define LLVM_HS_FOR_EACH_TARGET_OPTION_FLAG(macro)	\
-	macro(PrintMachineCode)																\
-	macro(UnsafeFPMath)																		\
-	macro(NoInfsFPMath)																		\
-	macro(NoNaNsFPMath)																		\
-	macro(NoTrappingFPMath)                               \
-	macro(NoSignedZerosFPMath)                            \
-	macro(HonorSignDependentRoundingFPMathOption)					\
-	macro(NoZerosInBSS)																		\
-	macro(GuaranteedTailCallOpt)													\
-	macro(StackSymbolOrdering)                            \
-	macro(EnableFastISel)																	\
-	macro(UseInitArray)																		\
-	macro(DisableIntegratedAS)														\
-	macro(RelaxELFRelocations)                            \
-	macro(FunctionSections)                               \
-	macro(DataSections)                                   \
-	macro(UniqueSectionNames)                             \
-	macro(TrapUnreachable)                                \
-	macro(EmulatedTLS)                                    \
-	macro(EnableIPRA)
+#define LLVM_HS_FOR_EACH_TARGET_OPTION_FLAG(macro)  \
+  macro(PrintMachineCode)                               \
+  macro(UnsafeFPMath)                                   \
+  macro(NoInfsFPMath)                                   \
+  macro(NoNaNsFPMath)                                   \
+  macro(NoTrappingFPMath)                               \
+  macro(NoSignedZerosFPMath)                            \
+  macro(HonorSignDependentRoundingFPMathOption)         \
+  macro(NoZerosInBSS)                                   \
+  macro(GuaranteedTailCallOpt)                          \
+  macro(StackSymbolOrdering)                            \
+  macro(EnableFastISel)                                 \
+  macro(UseInitArray)                                   \
+  macro(DisableIntegratedAS)                            \
+  macro(RelaxELFRelocations)                            \
+  macro(FunctionSections)                               \
+  macro(DataSections)                                   \
+  macro(UniqueSectionNames)                             \
+  macro(TrapUnreachable)                                \
+  macro(EmulatedTLS)                                    \
+  macro(EnableIPRA)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_TargetOptionFlag_ ## n,
-	LLVM_HS_FOR_EACH_TARGET_OPTION_FLAG(ENUM_CASE)
+  LLVM_HS_FOR_EACH_TARGET_OPTION_FLAG(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_TargetOptionFlag;
 
+#define LLVM_HS_FOR_EACH_MC_TARGET_OPTION_FLAG(macro)  \
+  macro(SanitizeAddress)                                \
+  macro(MCRelaxAll)                                     \
+  macro(MCNoExecStack)                                  \
+  macro(MCFatalWarnings)                                \
+  macro(MCNoWarn)                                       \
+  macro(MCNoDeprecatedWarn)                             \
+  macro(MCSaveTempLabels)                               \
+  macro(MCUseDwarfDirectory)                            \
+  macro(MCIncrementalLinkerCompatible)                  \
+  macro(MCPIECopyRelocations)                           \
+  macro(ShowMCEncoding)                                 \
+  macro(ShowMCInst)                                     \
+  macro(AsmVerbose)                                     \
+  macro(PreserveAsmComments)
+
+typedef enum {
+#define ENUM_CASE(n) LLVM_Hs_MCTargetOptionFlag_ ## n,
+  LLVM_HS_FOR_EACH_MC_TARGET_OPTION_FLAG(ENUM_CASE)
+#undef ENUM_CASE
+} LLVM_Hs_MCTargetOptionFlag;
+
 #define LLVM_HS_FOR_EACH_DEBUG_COMPRESSION_TYPE(macro) \
     macro(None) \
     macro(GNU) \
@@ -64,84 +86,84 @@
 #undef ENUM_CASE
 } LLVM_Hs_DebugCompressionType;
 
-#define LLVM_HS_FOR_EACH_FLOAT_ABI(macro)	\
-	macro(Default)																\
-	macro(Soft)																		\
-	macro(Hard)
+#define LLVM_HS_FOR_EACH_FLOAT_ABI(macro) \
+  macro(Default)                                \
+  macro(Soft)                                   \
+  macro(Hard)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_FloatABI_ ## n,
-	LLVM_HS_FOR_EACH_FLOAT_ABI(ENUM_CASE)
+  LLVM_HS_FOR_EACH_FLOAT_ABI(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_FloatABI;
 
-#define LLVM_HS_FOR_EACH_FP_OP_FUSION_MODE(macro)	\
-	macro(Fast)																						\
-	macro(Standard)																				\
-	macro(Strict)
+#define LLVM_HS_FOR_EACH_FP_OP_FUSION_MODE(macro) \
+  macro(Fast)                                           \
+  macro(Standard)                                       \
+  macro(Strict)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_FPOpFusionMode_ ## n,
-	LLVM_HS_FOR_EACH_FP_OP_FUSION_MODE(ENUM_CASE)
+  LLVM_HS_FOR_EACH_FP_OP_FUSION_MODE(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_FPOpFusionMode;
 
 #define LLVM_HS_FOR_EACH_THREAD_MODEL(macro) \
-	macro(POSIX) \
-	macro(Single)
+  macro(POSIX) \
+  macro(Single)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_ThreadModel_ ## n,
-	LLVM_HS_FOR_EACH_THREAD_MODEL(ENUM_CASE)
+  LLVM_HS_FOR_EACH_THREAD_MODEL(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_ThreadModel;
 
 #define LLVM_HS_FOR_EACH_EABI(macro) \
-	macro(Unknown)																				\
-	macro(Default)																				\
-	macro(EABI4)																					\
-	macro(EABI5)																					\
-	macro(GNU)
+  macro(Unknown)                                        \
+  macro(Default)                                        \
+  macro(EABI4)                                          \
+  macro(EABI5)                                          \
+  macro(GNU)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_EABI_ ## n,
-	LLVM_HS_FOR_EACH_EABI(ENUM_CASE)
+  LLVM_HS_FOR_EACH_EABI(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_EABI;
 
 #define LLVM_HS_FOR_EACH_DEBUGGER_KIND(macro) \
-	macro(Default)																				\
-	macro(GDB)																						\
-	macro(LLDB)																						\
-	macro(SCE)
+  macro(Default)                                        \
+  macro(GDB)                                            \
+  macro(LLDB)                                           \
+  macro(SCE)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_DebuggerKind_ ## n,
-	LLVM_HS_FOR_EACH_DEBUGGER_KIND(ENUM_CASE)
+  LLVM_HS_FOR_EACH_DEBUGGER_KIND(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_DebuggerKind;
 
 #define LLVM_HS_FOR_EACH_FP_DENORMAL_MODE(macro) \
-	macro(IEEE)																						\
-	macro(PreserveSign)																		\
-	macro(PositiveZero)
+  macro(IEEE)                                           \
+  macro(PreserveSign)                                   \
+  macro(PositiveZero)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_FPDenormalMode_ ## n,
-	LLVM_HS_FOR_EACH_FP_DENORMAL_MODE(ENUM_CASE)
+  LLVM_HS_FOR_EACH_FP_DENORMAL_MODE(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_FPDenormalMode;
 
 #define LLVM_HS_FOR_EACH_EXCEPTION_HANDLING(macro) \
-	macro(None)																						\
-	macro(DwarfCFI)																				\
-	macro(SjLj)																						\
-	macro(ARM)																						\
-	macro(WinEH)
+  macro(None)                                           \
+  macro(DwarfCFI)                                       \
+  macro(SjLj)                                           \
+  macro(ARM)                                            \
+  macro(WinEH)
 
 typedef enum {
 #define ENUM_CASE(n) LLVM_Hs_ExceptionHandling_ ## n,
-	LLVM_HS_FOR_EACH_EXCEPTION_HANDLING(ENUM_CASE)
+  LLVM_HS_FOR_EACH_EXCEPTION_HANDLING(ENUM_CASE)
 #undef ENUM_CASE
 } LLVM_Hs_ExceptionHandling;
 
diff --git a/src/LLVM/Internal/FFI/Target.hs b/src/LLVM/Internal/FFI/Target.hs
--- a/src/LLVM/Internal/FFI/Target.hs
+++ b/src/LLVM/Internal/FFI/Target.hs
@@ -24,6 +24,7 @@
     CString -> CString -> Ptr (OwnerTransfered CString) -> Ptr (OwnerTransfered CString) -> IO (Ptr Target)
 
 data TargetOptions
+data MCTargetOptions
 
 foreign import ccall unsafe "LLVM_Hs_CreateTargetOptions" createTargetOptions ::
   IO (Ptr TargetOptions)
@@ -34,6 +35,12 @@
 foreign import ccall unsafe "LLVM_Hs_GetTargetOptionFlag" getTargetOptionsFlag ::
   Ptr TargetOptions -> TargetOptionFlag -> IO LLVMBool
 
+foreign import ccall unsafe "LLVM_Hs_SetMCTargetOptionFlag" setMCTargetOptionFlag ::
+  Ptr MCTargetOptions -> MCTargetOptionFlag -> LLVMBool -> IO ()
+
+foreign import ccall unsafe "LLVM_Hs_GetMCTargetOptionFlag" getMCTargetOptionsFlag ::
+  Ptr MCTargetOptions -> MCTargetOptionFlag -> IO LLVMBool
+
 foreign import ccall unsafe "LLVM_Hs_GetCompressDebugSections" getCompressDebugSections ::
   Ptr TargetOptions -> IO DebugCompressionType
 
@@ -109,6 +116,9 @@
 
 foreign import ccall unsafe "LLVM_Hs_TargetMachineOptions" targetMachineOptions ::
   Ptr TargetMachine -> IO (Ptr TargetOptions)
+
+foreign import ccall unsafe "LLVM_Hs_MCTargetOptions" machineCodeOptions ::
+  Ptr TargetOptions -> IO (Ptr MCTargetOptions)
 
 foreign import ccall unsafe "LLVM_Hs_TargetMachineEmit" targetMachineEmit ::
   Ptr TargetMachine
diff --git a/src/LLVM/Internal/FFI/TargetC.cpp b/src/LLVM/Internal/FFI/TargetC.cpp
--- a/src/LLVM/Internal/FFI/TargetC.cpp
+++ b/src/LLVM/Internal/FFI/TargetC.cpp
@@ -1,4 +1,5 @@
 #define __STDC_LIMIT_MACROS
+#include "LLVM/Internal/FFI/ErrorHandling.hpp"
 #include "LLVM/Internal/FFI/LibFunc.h"
 #include "LLVM/Internal/FFI/Target.h"
 #include "LLVM/Internal/FFI/Target.hpp"
@@ -269,6 +270,18 @@
     }
 }
 
+void LLVM_Hs_SetMCTargetOptionFlag(MCTargetOptions *to, LLVM_Hs_MCTargetOptionFlag f,
+                                   unsigned v) {
+    switch (f) {
+#define ENUM_CASE(op)                                                          \
+    case LLVM_Hs_MCTargetOptionFlag_##op:                                      \
+        to->op = v ? 1 : 0;                                                    \
+        break;
+        LLVM_HS_FOR_EACH_MC_TARGET_OPTION_FLAG(ENUM_CASE)
+#undef ENUM_CASE
+    }
+}
+
 static llvm::DebugCompressionType
 unwrap(LLVM_Hs_DebugCompressionType compressionType) {
     switch (compressionType) {
@@ -278,7 +291,7 @@
         LLVM_HS_FOR_EACH_DEBUG_COMPRESSION_TYPE(ENUM_CASE)
 #undef ENUM_CASE
     default:
-        assert(false && "Unknown debug compression type");
+        reportFatalError("Unknown debug compression type");
         return llvm::DebugCompressionType::None;
     }
 }
@@ -292,7 +305,7 @@
         LLVM_HS_FOR_EACH_DEBUG_COMPRESSION_TYPE(ENUM_CASE)
 #undef ENUM_CASE
     default: {
-        assert(false && "Unknown debug compression type");
+        reportFatalError("Unknown debug compression type");
         return LLVM_Hs_DebugCompressionType_None;
     }
     }
@@ -317,11 +330,25 @@
         LLVM_HS_FOR_EACH_TARGET_OPTION_FLAG(ENUM_CASE)
 #undef ENUM_CASE
     default:
-        assert(false && "Unknown target option flag");
+        reportFatalError("Unknown target option flag");
         return 0;
     }
 }
 
+unsigned LLVM_Hs_GetMCTargetOptionFlag(MCTargetOptions *to,
+                                       LLVM_Hs_MCTargetOptionFlag f) {
+    switch (f) {
+#define ENUM_CASE(op)                                                          \
+    case LLVM_Hs_MCTargetOptionFlag_##op:                                      \
+        return to->op;
+        LLVM_HS_FOR_EACH_MC_TARGET_OPTION_FLAG(ENUM_CASE)
+#undef ENUM_CASE
+    default:
+        reportFatalError("Unknown machine code target option flag");
+        return 0;
+    }
+}
+
 void LLVM_Hs_SetStackAlignmentOverride(TargetOptions *to, unsigned v) {
     to->StackAlignmentOverride = v;
 }
@@ -470,8 +497,8 @@
 LLVMTargetMachineRef
 LLVM_Hs_CreateTargetMachine(LLVMTargetRef T, const char *Triple,
                             const char *CPU, const char *Features,
-                            TargetOptions *TO, LLVMCodeGenOptLevel Level,
-                            LLVMRelocMode Reloc, LLVMCodeModel CodeModel) {
+                            TargetOptions *TO, LLVMRelocMode Reloc,
+                            LLVMCodeModel CodeModel, LLVMCodeGenOptLevel Level) {
     Optional<Reloc::Model> RM;
     switch (Reloc) {
     case LLVMRelocStatic:
@@ -511,6 +538,10 @@
 
 TargetOptions *LLVM_Hs_TargetMachineOptions(LLVMTargetMachineRef TM) {
     return &unwrap(TM)->Options;
+}
+
+MCTargetOptions *LLVM_Hs_MCTargetOptions(TargetOptions *to) {
+    return &to->MCOptions;
 }
 
 // This is identical to LLVMTargetMachineEmit but LLVM doesn’t expose this
diff --git a/src/LLVM/Internal/Target.hs b/src/LLVM/Internal/Target.hs
--- a/src/LLVM/Internal/Target.hs
+++ b/src/LLVM/Internal/Target.hs
@@ -158,13 +158,15 @@
 -- | <http://llvm.org/doxygen/classllvm_1_1TargetOptions.html>
 newtype TargetOptions = TargetOptions (Ptr FFI.TargetOptions)
 
+newtype MCTargetOptions = MCTargetOptions (Ptr FFI.MCTargetOptions)
+
 -- | bracket creation and destruction of a 'TargetOptions' object
 withTargetOptions :: (TargetOptions -> IO a) -> IO a
 withTargetOptions = bracket FFI.createTargetOptions FFI.disposeTargetOptions . (. TargetOptions)
 
 -- | set all target options
 pokeTargetOptions :: TO.Options -> TargetOptions -> IO ()
-pokeTargetOptions hOpts (TargetOptions cOpts) = do
+pokeTargetOptions hOpts opts@(TargetOptions cOpts) = do
   mapM_ (\(c, ha) -> FFI.setTargetOptionFlag cOpts c =<< encodeM (ha hOpts)) [
     (FFI.targetOptionFlagPrintMachineCode, TO.printMachineCode),
     (FFI.targetOptionFlagUnsafeFPMath, TO.unsafeFloatingPointMath),
@@ -196,10 +198,30 @@
   FFI.setDebuggerTuning cOpts =<< encodeM (TO.debuggerTuning hOpts)
   FFI.setFPDenormalMode cOpts =<< encodeM (TO.floatingPointDenormalMode hOpts)
   FFI.setExceptionModel cOpts =<< encodeM (TO.exceptionModel hOpts)
+  pokeMachineCodeOptions (TO.machineCodeOptions hOpts) =<< machineCodeOptions opts
 
+pokeMachineCodeOptions :: TO.MachineCodeOptions -> MCTargetOptions -> IO ()
+pokeMachineCodeOptions hOpts (MCTargetOptions cOpts) =
+  mapM_ (\(c, ha) -> FFI.setMCTargetOptionFlag cOpts c =<< encodeM (ha hOpts)) [
+    (FFI.mcTargetOptionFlagSanitizeAddress, TO.sanitizeAddresses),
+    (FFI.mcTargetOptionFlagMCRelaxAll, TO.relaxAll),
+    (FFI.mcTargetOptionFlagMCNoExecStack, TO.noExecutableStack),
+    (FFI.mcTargetOptionFlagMCFatalWarnings, TO.fatalWarnings),
+    (FFI.mcTargetOptionFlagMCNoWarn, TO.noWarnings),
+    (FFI.mcTargetOptionFlagMCNoDeprecatedWarn, TO.noDeprecatedWarning),
+    (FFI.mcTargetOptionFlagMCSaveTempLabels, TO.saveTemporaryLabels),
+    (FFI.mcTargetOptionFlagMCUseDwarfDirectory, TO.useDwarfDirectory),
+    (FFI.mcTargetOptionFlagMCIncrementalLinkerCompatible, TO.incrementalLinkerCompatible),
+    (FFI.mcTargetOptionFlagMCPIECopyRelocations, TO.pieCopyRelocations),
+    (FFI.mcTargetOptionFlagShowMCEncoding, TO.showMachineCodeEncoding),
+    (FFI.mcTargetOptionFlagShowMCInst, TO.showMachineCodeInstructions),
+    (FFI.mcTargetOptionFlagAsmVerbose, TO.verboseAssembly),
+    (FFI.mcTargetOptionFlagPreserveAsmComments, TO.preserveComentsInAssembly)
+   ]
+
 -- | get all target options
 peekTargetOptions :: TargetOptions -> IO TO.Options
-peekTargetOptions (TargetOptions tOpts) = do
+peekTargetOptions opts@(TargetOptions tOpts) = do
   let gof = decodeM <=< FFI.getTargetOptionsFlag tOpts
   printMachineCode
     <- gof FFI.targetOptionFlagPrintMachineCode
@@ -250,8 +272,43 @@
   debuggerTuning <- decodeM =<< FFI.getDebuggerTuning tOpts
   floatingPointDenormalMode <- decodeM =<< FFI.getFPDenormalMode tOpts
   exceptionModel <- decodeM =<< FFI.getExceptionModel tOpts
+  machineCodeOptions <- peekMachineCodeOptions =<< machineCodeOptions opts
   return TO.Options { .. }
 
+-- | get all machine code options
+peekMachineCodeOptions :: MCTargetOptions -> IO TO.MachineCodeOptions
+peekMachineCodeOptions (MCTargetOptions tOpts) = do
+  let gof = decodeM <=< FFI.getMCTargetOptionsFlag tOpts
+  sanitizeAddresses
+    <- gof FFI.mcTargetOptionFlagSanitizeAddress
+  relaxAll
+    <- gof FFI.mcTargetOptionFlagMCRelaxAll
+  noExecutableStack
+    <- gof FFI.mcTargetOptionFlagMCNoExecStack
+  fatalWarnings
+    <- gof FFI.mcTargetOptionFlagMCFatalWarnings
+  noWarnings
+    <- gof FFI.mcTargetOptionFlagMCNoWarn
+  noDeprecatedWarning
+    <- gof FFI.mcTargetOptionFlagMCNoDeprecatedWarn
+  saveTemporaryLabels
+    <- gof FFI.mcTargetOptionFlagMCSaveTempLabels
+  useDwarfDirectory
+    <- gof FFI.mcTargetOptionFlagMCUseDwarfDirectory
+  incrementalLinkerCompatible
+    <- gof FFI.mcTargetOptionFlagMCIncrementalLinkerCompatible
+  pieCopyRelocations
+    <- gof FFI.mcTargetOptionFlagMCPIECopyRelocations
+  showMachineCodeEncoding
+    <- gof FFI.mcTargetOptionFlagShowMCEncoding
+  showMachineCodeInstructions
+    <- gof FFI.mcTargetOptionFlagShowMCInst
+  verboseAssembly
+    <- gof FFI.mcTargetOptionFlagAsmVerbose
+  preserveComentsInAssembly
+    <- gof FFI.mcTargetOptionFlagPreserveAsmComments
+  return TO.MachineCodeOptions { .. }
+
 -- | <http://llvm.org/doxygen/classllvm_1_1TargetMachine.html>
 newtype TargetMachine = TargetMachine (Ptr FFI.TargetMachine)
 
@@ -298,6 +355,9 @@
 
 targetMachineOptions :: TargetMachine -> IO TargetOptions
 targetMachineOptions (TargetMachine tm) = TargetOptions <$> FFI.targetMachineOptions tm
+
+machineCodeOptions :: TargetOptions -> IO MCTargetOptions
+machineCodeOptions (TargetOptions to) = MCTargetOptions <$> FFI.machineCodeOptions to
 
 -- | <http://llvm.org/doxygen/classllvm_1_1TargetLowering.html>
 newtype TargetLowering = TargetLowering (Ptr FFI.TargetLowering)
diff --git a/src/LLVM/Target/Options.hs b/src/LLVM/Target/Options.hs
--- a/src/LLVM/Target/Options.hs
+++ b/src/LLVM/Target/Options.hs
@@ -94,6 +94,26 @@
   eabiVersion :: EABIVersion,
   debuggerTuning :: DebuggerKind,
   floatingPointDenormalMode :: FloatingPointDenormalMode,
-  exceptionModel :: ExceptionHandling
+  exceptionModel :: ExceptionHandling,
+  machineCodeOptions :: MachineCodeOptions
+  }
+  deriving (Eq, Ord, Read, Show)
+
+-- | <http://llvm.org/doxygen/classllvm_1_1MCTargetOptions.html>
+data MachineCodeOptions = MachineCodeOptions {
+  sanitizeAddresses :: Bool,
+  relaxAll :: Bool,
+  noExecutableStack :: Bool,
+  fatalWarnings :: Bool,
+  noWarnings :: Bool,
+  noDeprecatedWarning :: Bool,
+  saveTemporaryLabels :: Bool,
+  useDwarfDirectory :: Bool,
+  incrementalLinkerCompatible :: Bool,
+  pieCopyRelocations :: Bool,
+  showMachineCodeEncoding :: Bool,
+  showMachineCodeInstructions :: Bool,
+  verboseAssembly :: Bool,
+  preserveComentsInAssembly :: Bool
   }
   deriving (Eq, Ord, Read, Show)
diff --git a/test/LLVM/Test/Module.hs b/test/LLVM/Test/Module.hs
--- a/test/LLVM/Test/Module.hs
+++ b/test/LLVM/Test/Module.hs
@@ -302,8 +302,6 @@
             \main:\n\
             \\t.cfi_startproc\n\
             \\txorl\t%eax, %eax\n\
-            \\tmovl\t%edi, -4(%rsp)\n\
-            \\tmovq\t%rsi, -16(%rsp)\n\
             \\tretq\n\
             \.Lfunc_end0:\n\
             \\t.size\tmain, .Lfunc_end0-main\n\
diff --git a/test/LLVM/Test/Target.hs b/test/LLVM/Test/Target.hs
--- a/test/LLVM/Test/Target.hs
+++ b/test/LLVM/Test/Target.hs
@@ -83,7 +83,26 @@
     debuggerTuning <- arbitrary
     floatingPointDenormalMode <- arbitrary
     exceptionModel <- arbitrary
+    machineCodeOptions <- arbitrary
     return Options { .. }
+
+instance Arbitrary MachineCodeOptions where
+  arbitrary = do
+    sanitizeAddresses <- arbitrary
+    relaxAll <- arbitrary
+    noExecutableStack <- arbitrary
+    fatalWarnings <- arbitrary
+    noWarnings <- arbitrary
+    noDeprecatedWarning <- arbitrary
+    saveTemporaryLabels <- arbitrary
+    useDwarfDirectory <- arbitrary
+    incrementalLinkerCompatible <- arbitrary
+    pieCopyRelocations <- arbitrary
+    showMachineCodeEncoding <- arbitrary
+    showMachineCodeInstructions <- arbitrary
+    verboseAssembly <- arbitrary
+    preserveComentsInAssembly <- arbitrary
+    return MachineCodeOptions { .. }
 
 instance Arbitrary DebugCompressionType where
   arbitrary = elements [CompressNone, CompressGNU, CompressZ]
