Exemple #1
0
 /// <summary>Initializes a new instance of the <see cref="TargetMachine"/> class.</summary>
 /// <param name="triple">Triple for the target machine</param>
 /// <param name="cpu">CPU options for the machine</param>
 /// <param name="features">CPU features for the machine</param>
 /// <param name="optLevel">General optimization level for machine code generation</param>
 /// <param name="relocationMode">Relocation mode for machine code generation</param>
 /// <param name="codeModel">Code model for machine code generation</param>
 public TargetMachine(Triple triple
                      , string?cpu                    = null
                      , string?features               = null
                      , CodeGenOpt optLevel           = CodeGenOpt.Default
                      , RelocationMode relocationMode = RelocationMode.Default
                      , CodeModel codeModel           = CodeModel.Default
                      )
     : this(Target.InternalCreateTargetMachine(Target.FromTriple(triple), triple, cpu, features, optLevel, relocationMode, codeModel))
 {
 }
Exemple #2
0
        /// <summary>Creates a <see cref="TargetMachine"/> for the triple and specified parameters</summary>
        /// <param name="triple">Target triple for this machine (e.g. -mtriple)</param>
        /// <param name="cpu">CPU for this machine (e.g. -mcpu)</param>
        /// <param name="features">Features for this machine (e.g. -mattr...)</param>
        /// <param name="optLevel">Optimization level</param>
        /// <param name="relocationMode">Relocation mode for generated code</param>
        /// <param name="codeModel"><see cref="CodeModel"/> to use for generated code</param>
        /// <returns><see cref="TargetMachine"/> based on the specified parameters</returns>
        public static TargetMachine FromTriple(Triple triple
                                               , string?cpu                    = null
                                               , string?features               = null
                                               , CodeGenOpt optLevel           = CodeGenOpt.Default
                                               , RelocationMode relocationMode = RelocationMode.Default
                                               , CodeModel codeModel           = CodeModel.Default
                                               )
        {
            var target = Target.FromTriple(triple);

            return(target.CreateTargetMachine(triple, cpu, features, optLevel, relocationMode, codeModel));
        }
Exemple #3
0
        /// <summary>Creates a <see cref="TargetMachine"/> for the target and specified parameters</summary>
        /// <param name="triple">Target triple for this machine (e.g. -mtriple)</param>
        /// <param name="cpu">CPU for this machine (e.g. -mcpu)</param>
        /// <param name="features">Features for this machine (e.g. -mattr...)</param>
        /// <param name="optLevel">Optimization level</param>
        /// <param name="relocationMode">Relocation mode for generated code</param>
        /// <param name="codeModel"><see cref="CodeModel"/> to use for generated code</param>
        /// <returns><see cref="TargetMachine"/> based on the specified parameters</returns>
        public TargetMachine CreateTargetMachine(string triple
                                                 , string cpu                    = null
                                                 , string features               = null
                                                 , CodeGenOpt optLevel           = CodeGenOpt.Default
                                                 , RelocationMode relocationMode = RelocationMode.Default
                                                 , CodeModel codeModel           = CodeModel.Default
                                                 )
        {
            LLVMTargetMachineRef targetMachineHandle = InternalCreateTargetMachine(this, triple, cpu, features, optLevel, relocationMode, codeModel);

            return(new TargetMachine(targetMachineHandle));
        }
Exemple #4
0
        /// <summary>Creates a <see cref="TargetMachine"/> for the target and specified parameters</summary>
        /// <param name="context">Context to use for LLVM objects created by this machine</param>
        /// <param name="triple">Target triple for this machine (e.g. -mtriple)</param>
        /// <param name="cpu">CPU for this machine (e.g. -mcpu)</param>
        /// <param name="features">Features for this machine (e.g. -mattr...)</param>
        /// <param name="optLevel">Optimization level</param>
        /// <param name="relocationMode">Relocation mode for generated code</param>
        /// <param name="codeModel"><see cref="CodeModel"/> to use for generated code</param>
        /// <returns><see cref="TargetMachine"/> based on the specified parameters</returns>
        public TargetMachine CreateTargetMachine(Context context
                                                 , string triple
                                                 , string cpu           = null
                                                 , string features      = null
                                                 , CodeGenOpt optLevel  = CodeGenOpt.Default
                                                 , Reloc relocationMode = Reloc.Default
                                                 , CodeModel codeModel  = CodeModel.Default
                                                 )
        {
            var targetMachineHandle = NativeMethods.CreateTargetMachine(TargetHandle
                                                                        , triple
                                                                        , cpu ?? string.Empty
                                                                        , features ?? string.Empty
                                                                        , ( LLVMCodeGenOptLevel )optLevel
                                                                        , ( LLVMRelocMode )relocationMode
                                                                        , ( LLVMCodeModel )codeModel
                                                                        );

            return(new TargetMachine(context, targetMachineHandle));
        }
Exemple #5
0
        /// <summary>Creates a <see cref="TargetMachine"/> for the target and specified parameters</summary>
        /// <param name="triple">Target triple for this machine (e.g. -mtriple)</param>
        /// <param name="cpu">CPU for this machine (e.g. -mcpu)</param>
        /// <param name="features">Features for this machine (e.g. -mattr...)</param>
        /// <param name="optLevel">Optimization level</param>
        /// <param name="relocationMode">Relocation mode for generated code</param>
        /// <param name="codeModel"><see cref="CodeModel"/> to use for generated code</param>
        /// <returns><see cref="TargetMachine"/> based on the specified parameters</returns>
        public TargetMachine CreateTargetMachine(string triple
                                                 , string cpu           = null
                                                 , string features      = null
                                                 , CodeGenOpt optLevel  = CodeGenOpt.Default
                                                 , Reloc relocationMode = Reloc.Default
                                                 , CodeModel codeModel  = CodeModel.Default
                                                 )
        {
            triple.ValidateNotNullOrWhiteSpace(nameof(triple));
            optLevel.ValidateDefined(nameof(optLevel));
            relocationMode.ValidateDefined(nameof(relocationMode));
            codeModel.ValidateDefined(nameof(codeModel));

            var targetMachineHandle = LLVMCreateTargetMachine(TargetHandle
                                                              , triple
                                                              , cpu ?? string.Empty
                                                              , features ?? string.Empty
                                                              , ( LLVMCodeGenOptLevel )optLevel
                                                              , ( LLVMRelocMode )relocationMode
                                                              , ( LLVMCodeModel )codeModel
                                                              );

            return(new TargetMachine(targetMachineHandle));
        }
Exemple #6
0
        internal static LLVMTargetMachineRef InternalCreateTargetMachine(Target target, string triple, string cpu, string features, CodeGenOpt optLevel, RelocationMode relocationMode, CodeModel codeModel)
        {
            triple.ValidateNotNullOrWhiteSpace(nameof(triple));
            optLevel.ValidateDefined(nameof(optLevel));
            relocationMode.ValidateDefined(nameof(relocationMode));
            codeModel.ValidateDefined(nameof(codeModel));

            var targetMachineHandle = LLVMCreateTargetMachine(target.TargetHandle
                                                              , triple
                                                              , cpu ?? string.Empty
                                                              , features ?? string.Empty
                                                              , ( LLVMCodeGenOptLevel )optLevel
                                                              , ( LLVMRelocMode )relocationMode
                                                              , ( LLVMCodeModel )codeModel
                                                              );

            return(targetMachineHandle);
        }
 /// <summary>Initializes a new instance of the <see cref="LegacyExecutionEngine"/> class with an initial module</summary>
 /// <param name="kind"><see cref="EngineKind"/> for the engine to create</param>
 /// <param name="optLevel">Optimization level for the engine</param>
 /// <remarks>This does not create the underlying engine, instead that is deferred until the first module is added</remarks>
 public LegacyExecutionEngine(EngineKind kind, CodeGenOpt optLevel)
 {
     Kind         = kind;
     Optimization = optLevel;
     OwnedModules = new Dictionary <int, LLVMModuleRef>( );
 }