While toLLVM fait

This commit is contained in:
Rochas
2025-04-10 21:23:32 +02:00
parent 99b6cbc08a
commit 3a009f7fac
7 changed files with 86 additions and 29 deletions

View File

@@ -30,19 +30,28 @@ public class ProgramLLVM {
//Instructon :
//Label
public static record LabelLLVMImp(String nom) implements InstructionLLVM{
public String prettyprinter(){
StringBuilder str = new StringBuilder();
return str.toString();
}
@Override
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
return v.visitLabelLLVM(this, h);
}
}
public static record BrLLVMImp(String label) implements InstructionLLVM{
@Override
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
return v.visitBrLLVM(this, h);
}
}
public static record BrCondLLVMImp(VarLLVMImpl var, String label, String labelElse) implements InstructionLLVM{
@Override
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
return v.visitBrCondLLVM(this, h);
}
}
public static record AssignLVMImpl(VarLLVMImpl var, ExpressionLLVM e) implements InstructionLLVM{
@Override
@@ -156,6 +165,18 @@ public class ProgramLLVM {
}
}
public static record IcmpLLVMImp(ValLLVM val1, ValLLVM val2) implements ExpressionLLVM{
@Override
public <H, S> S accept(ExpressionLLVMVisitor<H, S> v, H h) {
return v.visitIcmpLLVM(this, h);
}
@Override
public TypeLLVM getType() {
return new BooleanLLVMImp();
}
}
//Val
@@ -186,27 +207,24 @@ public class ProgramLLVM {
public static record IntLLVMImpl() implements TypeLLVM{
@Override
public <H, S> S accept(TypeLLVMVisitor<H, S> v, H h) {
return v.visitIntLLVM(this, h);
}
public int getNbBit(){
return 32;
}
}
public static record VoidLLVMImpl() implements TypeLLVM{
@Override
public <H, S> S accept(TypeLLVMVisitor<H, S> v, H h) {
return v.visitVoidLLVM(this, h);
}
}
public int getNbBit(){
return 0;
public static record BooleanLLVMImp() implements TypeLLVM{
@Override
public <H, S> S accept(TypeLLVMVisitor<H, S> v, H h) {
return v.visitBooleanLLVM(this, h);
}
}
}