llvmir some opt
This commit is contained in:
26
midend/llvm/instr/PutStrInstr.java
Normal file
26
midend/llvm/instr/PutStrInstr.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package midend.llvm.instr;
|
||||
|
||||
import midend.llvm.type.IrInterType;
|
||||
import midend.llvm.type.IrPointerType;
|
||||
import midend.llvm.constant.IrConstantStr;
|
||||
|
||||
public class PutStrInstr extends IrInstr {
|
||||
private IrConstantStr strVal;
|
||||
|
||||
public PutStrInstr(String name, IrConstantStr putValue) {
|
||||
super(IrInterType.VOID, name, IrInstrType.IO);
|
||||
addUse(putValue);
|
||||
strVal = putValue;
|
||||
}
|
||||
|
||||
public static String putStrDecl() {
|
||||
return "declare void @putstr(i8*)";
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
IrPointerType ptrType = (IrPointerType) strVal.getType();
|
||||
return "call void @putstr(i8* getelementptr inbounds ("
|
||||
+ ptrType.getPointeeType() + ", " + ptrType +
|
||||
" " + strVal.getName() + ", i32 0, i32 0))";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user