forked from OSchip/llvm-project
Add upport for bitcast in the C API echo test
llvm-svn: 261177
This commit is contained in:
parent
71434ff642
commit
40bbe519e5
|
@ -276,12 +276,24 @@ LLVMValueRef clone_constant(LLVMValueRef Cst, LLVMModuleRef M) {
|
|||
if (LLVMIsUndef(Cst))
|
||||
return LLVMGetUndef(TypeCloner(M).Clone(Cst));
|
||||
|
||||
// Try float literal
|
||||
if (LLVMIsAConstantFP(Cst))
|
||||
report_fatal_error("ConstantFP is not supported");
|
||||
|
||||
// This kind of constant is not supported
|
||||
if (!LLVMIsAConstantExpr(Cst))
|
||||
report_fatal_error("Expected a constant expression");
|
||||
|
||||
// At this point, it must be a constant expression
|
||||
report_fatal_error("ConstantExpression are not supported");
|
||||
LLVMOpcode Op = LLVMGetConstOpcode(Cst);
|
||||
switch(Op) {
|
||||
case LLVMBitCast:
|
||||
return LLVMConstBitCast(clone_constant(LLVMGetOperand(Cst, 0), M),
|
||||
TypeCloner(M).Clone(Cst));
|
||||
default:
|
||||
fprintf(stderr, "%d is not a supported opcode\n", Op);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
struct FunCloner {
|
||||
|
@ -489,6 +501,11 @@ struct FunCloner {
|
|||
Dst = LLVMBuildGEP(Builder, Ptr, Idx.data(), NumIdx, Name);
|
||||
break;
|
||||
}
|
||||
case LLVMBitCast: {
|
||||
LLVMValueRef V = CloneValue(LLVMGetOperand(Src, 0));
|
||||
Dst = LLVMBuildBitCast(Builder, V, CloneType(Src), Name);
|
||||
break;
|
||||
}
|
||||
case LLVMICmp: {
|
||||
LLVMIntPredicate Pred = LLVMGetICmpPredicate(Src);
|
||||
LLVMValueRef LHS = CloneValue(LLVMGetOperand(Src, 0));
|
||||
|
|
Loading…
Reference in New Issue