mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
add some more hooks to the C bindings, patch by Kenneth Uildriks!
llvm-svn: 83821
This commit is contained in:
parent
839b87c053
commit
b2e0e6c46b
@ -89,6 +89,12 @@ typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef;
|
||||
/** See the llvm::PassManagerBase class. */
|
||||
typedef struct LLVMOpaquePassManager *LLVMPassManagerRef;
|
||||
|
||||
/**
|
||||
* Used to iterate through the uses of a Value, allowing access to all Values
|
||||
* that use this Value. See the llvm::Use and llvm::value_use_iterator classes.
|
||||
*/
|
||||
typedef struct LLVMOpaqueUseIterator *LLVMUseIteratorRef;
|
||||
|
||||
typedef enum {
|
||||
LLVMZExtAttribute = 1<<0,
|
||||
LLVMSExtAttribute = 1<<1,
|
||||
@ -113,6 +119,62 @@ typedef enum {
|
||||
LLVMInlineHintAttribute = 1<<25
|
||||
} LLVMAttribute;
|
||||
|
||||
typedef enum {
|
||||
LLVMRet = 1,
|
||||
LLVMBr = 2,
|
||||
LLVMSwitch = 3,
|
||||
LLVMInvoke = 4,
|
||||
LLVMUnwind = 5,
|
||||
LLVMUnreachable = 6,
|
||||
LLVMAdd = 7,
|
||||
LLVMFAdd = 8,
|
||||
LLVMSub = 9,
|
||||
LLVMFSub = 10,
|
||||
LLVMMul = 11,
|
||||
LLVMFMul = 12,
|
||||
LLVMUDiv = 13,
|
||||
LLVMSDiv = 14,
|
||||
LLVMFDiv = 15,
|
||||
LLVMURem = 16,
|
||||
LLVMSRem = 17,
|
||||
LLVMFRem = 18,
|
||||
LLVMShl = 19,
|
||||
LLVMLShr = 20,
|
||||
LLVMAShr = 21,
|
||||
LLVMAnd = 22,
|
||||
LLVMOr = 23,
|
||||
LLVMXor = 24,
|
||||
LLVMMalloc = 25,
|
||||
LLVMFree = 26,
|
||||
LLVMAlloca = 27,
|
||||
LLVMLoad = 28,
|
||||
LLVMStore = 29,
|
||||
LLVMGetElementPtr = 30,
|
||||
LLVMTrunk = 31,
|
||||
LLVMZExt = 32,
|
||||
LLVMSExt = 33,
|
||||
LLVMFPToUI = 34,
|
||||
LLVMFPToSI = 35,
|
||||
LLVMUIToFP = 36,
|
||||
LLVMSIToFP = 37,
|
||||
LLVMFPTrunc = 38,
|
||||
LLVMFPExt = 39,
|
||||
LLVMPtrToInt = 40,
|
||||
LLVMIntToPtr = 41,
|
||||
LLVMBitCast = 42,
|
||||
LLVMICmp = 43,
|
||||
LLVMFCmp = 44,
|
||||
LLVMPHI = 45,
|
||||
LLVMCall = 46,
|
||||
LLVMSelect = 47,
|
||||
LLVMVAArg = 50,
|
||||
LLVMExtractElement = 51,
|
||||
LLVMInsertElement = 52,
|
||||
LLVMShuffleVector = 53,
|
||||
LLVMExtractValue = 54,
|
||||
LLVMInsertValue = 55
|
||||
} LLVMOpcode;
|
||||
|
||||
typedef enum {
|
||||
LLVMVoidTypeKind, /**< type with no size */
|
||||
LLVMFloatTypeKind, /**< 32 bit floating point type */
|
||||
@ -419,6 +481,7 @@ LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
|
||||
const char *LLVMGetValueName(LLVMValueRef Val);
|
||||
void LLVMSetValueName(LLVMValueRef Val, const char *Name);
|
||||
void LLVMDumpValue(LLVMValueRef Val);
|
||||
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal);
|
||||
|
||||
/* Conversion functions. Return the input value if it is an instance of the
|
||||
specified class, otherwise NULL. See llvm::dyn_cast_or_null<>. */
|
||||
@ -426,6 +489,15 @@ void LLVMDumpValue(LLVMValueRef Val);
|
||||
LLVMValueRef LLVMIsA##name(LLVMValueRef Val);
|
||||
LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST)
|
||||
|
||||
/* Operations on Uses */
|
||||
LLVMUseIteratorRef LLVMGetFirstUse(LLVMValueRef Val);
|
||||
LLVMUseIteratorRef LLVMGetNextUse(LLVMUseIteratorRef U);
|
||||
LLVMValueRef LLVMGetUser(LLVMUseIteratorRef U);
|
||||
LLVMValueRef LLVMGetUsedValue(LLVMUseIteratorRef U);
|
||||
|
||||
/* Operations on Users */
|
||||
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index);
|
||||
|
||||
/* Operations on constants of any type */
|
||||
LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); /* all zeroes */
|
||||
LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); /* only for int/vector */
|
||||
@ -446,6 +518,8 @@ LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N);
|
||||
LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text);
|
||||
LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text,
|
||||
unsigned SLen);
|
||||
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal);
|
||||
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal);
|
||||
|
||||
|
||||
/* Operations on composite constants */
|
||||
@ -464,6 +538,7 @@ LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
|
||||
LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size);
|
||||
|
||||
/* Constant expressions */
|
||||
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal);
|
||||
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty);
|
||||
LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty);
|
||||
LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal);
|
||||
@ -587,6 +662,7 @@ void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC);
|
||||
const char *LLVMGetGC(LLVMValueRef Fn);
|
||||
void LLVMSetGC(LLVMValueRef Fn, const char *Name);
|
||||
void LLVMAddFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
|
||||
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn);
|
||||
void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA);
|
||||
|
||||
/* Operations on parameters */
|
||||
@ -600,6 +676,7 @@ LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg);
|
||||
LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg);
|
||||
void LLVMAddAttribute(LLVMValueRef Arg, LLVMAttribute PA);
|
||||
void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA);
|
||||
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg);
|
||||
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align);
|
||||
|
||||
/* Operations on basic blocks */
|
||||
@ -950,6 +1027,7 @@ namespace llvm {
|
||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ModuleProvider, LLVMModuleProviderRef)
|
||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
|
||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef )
|
||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseIteratorRef )
|
||||
DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef )
|
||||
|
||||
#undef DEFINE_STDCXX_CONVERSION_FUNCTIONS
|
||||
|
@ -389,6 +389,9 @@ void LLVMDumpValue(LLVMValueRef Val) {
|
||||
unwrap(Val)->dump();
|
||||
}
|
||||
|
||||
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal) {
|
||||
unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
|
||||
}
|
||||
|
||||
/*--.. Conversion functions ................................................--*/
|
||||
|
||||
@ -399,6 +402,31 @@ void LLVMDumpValue(LLVMValueRef Val) {
|
||||
|
||||
LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DEFINE_VALUE_CAST)
|
||||
|
||||
/*--.. Operations on Uses ..................................................--*/
|
||||
LLVMUseIteratorRef LLVMGetFirstUse(LLVMValueRef Val) {
|
||||
Value *V = unwrap(Val);
|
||||
Value::use_iterator I = V->use_begin();
|
||||
if (I == V->use_end())
|
||||
return 0;
|
||||
return wrap(&(I.getUse()));
|
||||
}
|
||||
|
||||
LLVMUseIteratorRef LLVMGetNextUse(LLVMUseIteratorRef UR) {
|
||||
return wrap(unwrap(UR)->getNext());
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetUser(LLVMUseIteratorRef UR) {
|
||||
return wrap(unwrap(UR)->getUser());
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetUsedValue(LLVMUseIteratorRef UR) {
|
||||
return wrap(unwrap(UR)->get());
|
||||
}
|
||||
|
||||
/*--.. Operations on Users .................................................--*/
|
||||
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index) {
|
||||
return wrap(unwrap<User>(Val)->getOperand(Index));
|
||||
}
|
||||
|
||||
/*--.. Operations on constants of any type .................................--*/
|
||||
|
||||
@ -465,6 +493,14 @@ LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char Str[],
|
||||
return wrap(ConstantFP::get(unwrap(RealTy), StringRef(Str, SLen)));
|
||||
}
|
||||
|
||||
unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal) {
|
||||
return unwrap<ConstantInt>(ConstantVal)->getZExtValue();
|
||||
}
|
||||
|
||||
long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal) {
|
||||
return unwrap<ConstantInt>(ConstantVal)->getSExtValue();
|
||||
}
|
||||
|
||||
/*--.. Operations on composite constants ...................................--*/
|
||||
|
||||
LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str,
|
||||
@ -506,6 +542,10 @@ LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
|
||||
|
||||
/*--.. Constant expressions ................................................--*/
|
||||
|
||||
LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal) {
|
||||
return (LLVMOpcode)unwrap<ConstantExpr>(ConstantVal)->getOpcode();
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty) {
|
||||
return wrap(ConstantExpr::getAlignOf(unwrap(Ty)));
|
||||
}
|
||||
@ -1027,7 +1067,10 @@ void LLVMDeleteGlobal(LLVMValueRef GlobalVar) {
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar) {
|
||||
return wrap(unwrap<GlobalVariable>(GlobalVar)->getInitializer());
|
||||
GlobalVariable* GV = unwrap<GlobalVariable>(GlobalVar);
|
||||
if ( !GV->hasInitializer() )
|
||||
return 0;
|
||||
return wrap(GV->getInitializer());
|
||||
}
|
||||
|
||||
void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
|
||||
@ -1149,6 +1192,13 @@ void LLVMRemoveFunctionAttr(LLVMValueRef Fn, LLVMAttribute PA) {
|
||||
Func->setAttributes(PALnew);
|
||||
}
|
||||
|
||||
LLVMAttribute LLVMGetFunctionAttr(LLVMValueRef Fn) {
|
||||
Function *Func = unwrap<Function>(Fn);
|
||||
const AttrListPtr PAL = Func->getAttributes();
|
||||
Attributes attr = PAL.getFnAttributes();
|
||||
return (LLVMAttribute)attr;
|
||||
}
|
||||
|
||||
/*--.. Operations on parameters ............................................--*/
|
||||
|
||||
unsigned LLVMCountParams(LLVMValueRef FnRef) {
|
||||
@ -1215,6 +1265,14 @@ void LLVMRemoveAttribute(LLVMValueRef Arg, LLVMAttribute PA) {
|
||||
unwrap<Argument>(Arg)->removeAttr(PA);
|
||||
}
|
||||
|
||||
LLVMAttribute LLVMGetAttribute(LLVMValueRef Arg) {
|
||||
Argument *A = unwrap<Argument>(Arg);
|
||||
Attributes attr = A->getParent()->getAttributes().getParamAttributes(
|
||||
A->getArgNo()+1);
|
||||
return (LLVMAttribute)attr;
|
||||
}
|
||||
|
||||
|
||||
void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
|
||||
unwrap<Argument>(Arg)->addAttr(
|
||||
Attribute::constructAlignmentFromInt(align));
|
||||
|
Loading…
x
Reference in New Issue
Block a user