mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
C bindings for Module-, Function-, and BasicBlock::iterator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48528 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3a4c856323
commit
3400097966
@ -389,6 +389,10 @@ void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, int IsConstant);
|
||||
LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name,
|
||||
LLVMTypeRef FunctionTy);
|
||||
LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name);
|
||||
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M);
|
||||
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn);
|
||||
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn);
|
||||
void LLVMDeleteFunction(LLVMValueRef Fn);
|
||||
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
|
||||
unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn);
|
||||
@ -409,6 +413,10 @@ LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val);
|
||||
LLVMValueRef LLVMGetBasicBlockParent(LLVMValueRef V);
|
||||
unsigned LLVMCountBasicBlocks(LLVMValueRef Fn);
|
||||
void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks);
|
||||
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn);
|
||||
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn);
|
||||
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB);
|
||||
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
|
||||
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
|
||||
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name);
|
||||
LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB,
|
||||
@ -417,6 +425,10 @@ void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB);
|
||||
|
||||
/* Operations on instructions */
|
||||
LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst);
|
||||
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB);
|
||||
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB);
|
||||
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst);
|
||||
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst);
|
||||
|
||||
/* Operations on call sites */
|
||||
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC);
|
||||
@ -436,6 +448,8 @@ LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index);
|
||||
*/
|
||||
|
||||
LLVMBuilderRef LLVMCreateBuilder();
|
||||
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
|
||||
LLVMValueRef Instr);
|
||||
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr);
|
||||
void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block);
|
||||
LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder);
|
||||
|
@ -601,6 +601,38 @@ LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name) {
|
||||
return wrap(unwrap(M)->getNamedGlobal(Name));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M) {
|
||||
Module *Mod = unwrap(M);
|
||||
Module::global_iterator I = Mod->global_begin();
|
||||
if (I == Mod->global_end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M) {
|
||||
Module *Mod = unwrap(M);
|
||||
Module::global_iterator I = Mod->global_end();
|
||||
if (I == Mod->global_begin())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar) {
|
||||
GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
|
||||
Module::global_iterator I = GV;
|
||||
if (++I == GV->getParent()->global_end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar) {
|
||||
GlobalVariable *GV = unwrap<GlobalVariable>(GlobalVar);
|
||||
Module::global_iterator I = GV;
|
||||
if (I == GV->getParent()->global_end())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
void LLVMDeleteGlobal(LLVMValueRef GlobalVar) {
|
||||
unwrap<GlobalVariable>(GlobalVar)->eraseFromParent();
|
||||
}
|
||||
@ -646,6 +678,38 @@ LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name) {
|
||||
return wrap(unwrap(M)->getFunction(Name));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M) {
|
||||
Module *Mod = unwrap(M);
|
||||
Module::iterator I = Mod->begin();
|
||||
if (I == Mod->end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M) {
|
||||
Module *Mod = unwrap(M);
|
||||
Module::iterator I = Mod->end();
|
||||
if (I == Mod->begin())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn) {
|
||||
Function *Func = unwrap<Function>(Fn);
|
||||
Module::iterator I = Func;
|
||||
if (++I == Func->getParent()->end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn) {
|
||||
Function *Func = unwrap<Function>(Fn);
|
||||
Module::iterator I = Func;
|
||||
if (I == Func->getParent()->end())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
void LLVMDeleteFunction(LLVMValueRef Fn) {
|
||||
unwrap<Function>(Fn)->eraseFromParent();
|
||||
}
|
||||
@ -735,6 +799,38 @@ LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn) {
|
||||
return wrap(&unwrap<Function>(Fn)->getEntryBlock());
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn) {
|
||||
Function *Func = unwrap<Function>(Fn);
|
||||
Function::iterator I = Func->begin();
|
||||
if (I == Func->end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn) {
|
||||
Function *Func = unwrap<Function>(Fn);
|
||||
Function::iterator I = Func->end();
|
||||
if (I == Func->begin())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB) {
|
||||
BasicBlock *Block = unwrap(BB);
|
||||
Function::iterator I = Block;
|
||||
if (++I == Block->getParent()->end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB) {
|
||||
BasicBlock *Block = unwrap(BB);
|
||||
Function::iterator I = Block;
|
||||
if (I == Block->getParent()->begin())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef FnRef, const char *Name) {
|
||||
return wrap(new BasicBlock(Name, unwrap<Function>(FnRef)));
|
||||
}
|
||||
@ -756,6 +852,38 @@ LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst) {
|
||||
return wrap(unwrap<Instruction>(Inst)->getParent());
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB) {
|
||||
BasicBlock *Block = unwrap(BB);
|
||||
BasicBlock::iterator I = Block->begin();
|
||||
if (I == Block->end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB) {
|
||||
BasicBlock *Block = unwrap(BB);
|
||||
BasicBlock::iterator I = Block->end();
|
||||
if (I == Block->begin())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst) {
|
||||
Instruction *Instr = unwrap<Instruction>(Inst);
|
||||
BasicBlock::iterator I = Instr;
|
||||
if (++I == Instr->getParent()->end())
|
||||
return 0;
|
||||
return wrap(I);
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst) {
|
||||
Instruction *Instr = unwrap<Instruction>(Inst);
|
||||
BasicBlock::iterator I = Instr;
|
||||
if (I == Instr->getParent()->begin())
|
||||
return 0;
|
||||
return wrap(--I);
|
||||
}
|
||||
|
||||
/*--.. Call and invoke instructions ........................................--*/
|
||||
|
||||
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) {
|
||||
@ -805,6 +933,13 @@ LLVMBuilderRef LLVMCreateBuilder() {
|
||||
return wrap(new LLVMFoldingBuilder());
|
||||
}
|
||||
|
||||
void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block,
|
||||
LLVMValueRef Instr) {
|
||||
BasicBlock *BB = unwrap(Block);
|
||||
Instruction *I = Instr? unwrap<Instruction>(Instr) : (Instruction*) BB->end();
|
||||
unwrap(Builder)->SetInsertPoint(BB, I);
|
||||
}
|
||||
|
||||
void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr) {
|
||||
Instruction *I = unwrap<Instruction>(Instr);
|
||||
unwrap(Builder)->SetInsertPoint(I->getParent(), I);
|
||||
|
Loading…
x
Reference in New Issue
Block a user