binding for Target, Triple, TargetMachine
This commit is contained in:
parent
ca0a2b9fdd
commit
9485d03e18
9 changed files with 199 additions and 8 deletions
|
|
@ -17,3 +17,4 @@ class TLSModel:
|
|||
class CodeGenOpt:
|
||||
'Actually a namespace'
|
||||
Level = Enum('None', 'Less', 'Default', 'Aggressive')
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from CodeGen import CodeGenOpt, Reloc, CodeModel
|
|||
from StringRef import StringRef
|
||||
from ExecutionEngine import ExecutionEngine
|
||||
from TargetMachine import TargetMachine
|
||||
from Triple import Triple
|
||||
|
||||
EngineBuilder = llvm.Class()
|
||||
|
||||
|
|
@ -45,5 +46,17 @@ class EngineBuilder:
|
|||
create = Method(ptr(ExecutionEngine),
|
||||
ownedptr(TargetMachine)).require_only(0)
|
||||
|
||||
selectTarget = Method(ptr(TargetMachine))
|
||||
_selectTarget0 = Method(ptr(TargetMachine))
|
||||
_selectTarget0.realname = 'selectTarget'
|
||||
|
||||
_selectTarget1 = CustomMethod('EngineBuilder_selectTarget',
|
||||
const(ref(Triple)), cast(str, StringRef),
|
||||
cast(str, StringRef), PyObjectPtr),
|
||||
|
||||
@CustomPythonMethod
|
||||
def selectTarget(self, *args):
|
||||
if not args:
|
||||
return self._selectTarget0()
|
||||
else:
|
||||
return self._selectTarget1(*args)
|
||||
|
||||
|
|
|
|||
27
newbinding/src/Target.py
Normal file
27
newbinding/src/Target.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from StringRef import StringRef
|
||||
Target = llvm.Class()
|
||||
|
||||
@Target
|
||||
class Target:
|
||||
_include_ = 'llvm/Support/TargetRegistry.h'
|
||||
|
||||
getNext = Method(const(ptr(Target)))
|
||||
|
||||
getName = Method(cast(StringRef, str))
|
||||
getShortDescription = Method(cast(StringRef, str))
|
||||
|
||||
def _has():
|
||||
return Method(cast(Bool, bool))
|
||||
|
||||
hasJIT = _has()
|
||||
hasTargetMachine = _has()
|
||||
hasMCAsmBackend = _has()
|
||||
hasMCAsmParser = _has()
|
||||
hasAsmPrinter = _has()
|
||||
hasMCDisassembler = _has()
|
||||
hasMCInstPrinter = _has()
|
||||
hasMCCodeEmitter = _has()
|
||||
hasMCObjectStreamer = _has()
|
||||
hasAsmStreamer = _has()
|
||||
|
|
@ -1,5 +1,12 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from StringRef import StringRef
|
||||
from CodeGen import CodeModel, TLSModel, CodeGenOpt, Reloc
|
||||
from GlobalValue import GlobalValue
|
||||
from Target import Target
|
||||
from DataLayout import DataLayout
|
||||
from TargetTransformInfo import (ScalarTargetTransformInfo,
|
||||
VectorTargetTransformInfo)
|
||||
|
||||
TargetMachine = llvm.Class()
|
||||
|
||||
|
|
@ -8,4 +15,22 @@ class TargetMachine:
|
|||
_include_ = 'llvm/Target/TargetMachine.h'
|
||||
delete = Destructor()
|
||||
|
||||
getTarget = Method(const(ref(Target)))
|
||||
|
||||
getTargetTriple = Method(cast(StringRef, str))
|
||||
getTargetCPU = Method(cast(StringRef, str))
|
||||
getTargetFeatureString = Method(cast(StringRef, str))
|
||||
|
||||
getRelocationModel = Method(Reloc.Model)
|
||||
getCodeModel = Method(CodeModel.Model)
|
||||
getTLSModel = Method(TLSModel.Model, ptr(GlobalValue))
|
||||
getOptLevel = Method(CodeGenOpt.Level)
|
||||
|
||||
hasMCUseDwarfDirectory = Method(cast(Bool, bool))
|
||||
setMCUseDwarfDirectory = Method(Void, cast(bool, Bool))
|
||||
|
||||
getDataLayout = Method(const(ownedptr(DataLayout)))
|
||||
getScalarTargetTransformInfo = Method(const(
|
||||
ownedptr(ScalarTargetTransformInfo)))
|
||||
getVectorTargetTransformInfo = Method(const(
|
||||
ownedptr(VectorTargetTransformInfo)))
|
||||
|
|
|
|||
14
newbinding/src/TargetTransformInfo.py
Normal file
14
newbinding/src/TargetTransformInfo.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
|
||||
ScalarTargetTransformInfo = llvm.Class()
|
||||
VectorTargetTransformInfo = llvm.Class()
|
||||
|
||||
@ScalarTargetTransformInfo
|
||||
class ScalarTargetTransformInfo:
|
||||
delete = Destructor()
|
||||
|
||||
@VectorTargetTransformInfo
|
||||
class VectorTargetTransformInfo:
|
||||
delete = Destructor()
|
||||
|
||||
55
newbinding/src/Triple.py
Normal file
55
newbinding/src/Triple.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from StringRef import StringRef
|
||||
|
||||
Triple = llvm.Class()
|
||||
|
||||
@Triple
|
||||
class Triple:
|
||||
_include_ = 'llvm/ADT/Triple.h'
|
||||
|
||||
new = Constructor()
|
||||
new |= Constructor(cast(str, StringRef))
|
||||
new |= Constructor(cast(str, StringRef),
|
||||
cast(str, StringRef), cast(str, StringRef))
|
||||
|
||||
def _return_str():
|
||||
return Method(cast(StringRef, str))
|
||||
|
||||
getTriple = _return_str()
|
||||
getArchName = _return_str()
|
||||
getVendorName = _return_str()
|
||||
getOSName = _return_str()
|
||||
getEnvironmentName = _return_str()
|
||||
getOSAndEnvironmentName = _return_str()
|
||||
|
||||
@CustomPythonMethod
|
||||
def __str__(self):
|
||||
return self.getTriple()
|
||||
|
||||
def _return_bool(*args):
|
||||
return Method(cast(bool, Bool), *args)
|
||||
|
||||
isArch64Bit = _return_bool()
|
||||
isArch32Bit = _return_bool()
|
||||
isArch16Bit = _return_bool()
|
||||
isOSVersionLT = _return_bool(cast(int, Unsigned),
|
||||
cast(int, Unsigned),
|
||||
cast(int, Unsigned)).require_only(1)
|
||||
|
||||
isMacOSXVersionLT = _return_bool(cast(int, Unsigned),
|
||||
cast(int, Unsigned),
|
||||
cast(int, Unsigned)).require_only(1)
|
||||
|
||||
isMacOSX = _return_bool()
|
||||
isOSDarwin = _return_bool()
|
||||
isOSCygMing = _return_bool()
|
||||
isOSWindows = _return_bool()
|
||||
# isOSNaCl = _return_bool()
|
||||
isOSBinFormatELF = _return_bool()
|
||||
isOSBinFormatCOFF = _return_bool()
|
||||
isEnvironmentMachO = _return_bool()
|
||||
|
||||
get32BitArchVariant = Method(Triple)
|
||||
get64BitArchVariant = Method(Triple)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue