tinysnail 3 years ago
commit 3deb33ed04

@ -25,17 +25,17 @@
``` log ``` log
. .
├── CMakeLists.txt ├── CMakeLists.txt
├── README.md <- PW6 ├── README.md <-
├── doc ├── doc
│   ├── AST.md │   ├── AST.md
│   ├── phase1.md <- │   ├── phase1.md <-
│   ├── phase2.md │   ├── phase2.md
│   ├── phase3.md │   ├── phase3.md
│   ├── SysYF语言定义.pdf │   ├── SysYF语言定义.pdf
| └── SysYFIR.md <- SysYF IR | └── SysYFIR.md <- SysYF IR
├── report ├── report
│   ├── report.md <- PW6 │   ├── report.md <-
│   └── contribution.md <- PW6 │   └── contribution.md <-
├── include <- ├── include <-
│   ├── ... │   ├── ...
│   └── SysYFIR │   └── SysYFIR
@ -44,11 +44,11 @@
│   ├── SysYFIR │   ├── SysYFIR
│   └── SysYFIRBuilder │   └── SysYFIRBuilder
| ├── CMakeLists.txt | ├── CMakeLists.txt
| └── IRBuilder.cpp <- | └── IRBuilder.cpp <-
└── Student └── Student
├── CMakeLists.txt ├── CMakeLists.txt
├── task1 ├── task1 <-
| ├── ll <- PW6.ll | ├── ll <- LLVM IR(.ll)
| | ├── assign_hand.ll | | ├── assign_hand.ll
|   │   ├── fun_hand.ll |   │   ├── fun_hand.ll
|   │   ├── if_hand.ll |   │   ├── if_hand.ll
@ -60,8 +60,8 @@
|   │   └── while_test.sy |   │   └── while_test.sy
| └── demo | └── demo
|      └── go_upstairs.c |      └── go_upstairs.c
├── task2 ├── task2 <-
| ├── cpp <- PW6.cpp | ├── cpp <- .cpp
| | ├── CMakeLists.txt | | ├── CMakeLists.txt
| | ├── assign_gen.cpp | | ├── assign_gen.cpp
|   │   ├── fun_gen.cpp |   │   ├── fun_gen.cpp
@ -75,10 +75,10 @@
| └── demo | └── demo
|      |── CMakeLists.txt |      |── CMakeLists.txt
|      |── go_upstairs.sy |      |── go_upstairs.sy
|      └── go_upstairs_gen.cpp <- go_upstairs.llcpp |      └── go_upstairs_gen.cpp <- go_upstairs.llcpp
└── task3 └── task3
└── test └── test
├── test.py <- PW6 ├── test.py <-
└── test <- └── test <-
``` ```

@ -1,13 +0,0 @@
#include "Value.h"
#include "Module.h"
#include "Function.h"
#include "GlobalVariable.h"
#include "Constant.h"
#include "BasicBlock.h"
#include "Instruction.h"
#include "User.h"
#include "Type.h"
std::string print_as_op( Value *v, bool print_ty );
std::string print_cmp_type( CmpInst::CmpOp op);
std::string print_fcmp_type( FCmpInst::CmpOp op);

@ -1,86 +0,0 @@
#include "IRPrinter.h"
std::string print_as_op( Value *v, bool print_ty )
{
std::string op_ir;
if( print_ty )
{
op_ir += v->get_type()->print();
op_ir += " ";
}
if (dynamic_cast<GlobalVariable *>(v))
{
op_ir += "@"+v->get_name();
}
else if ( dynamic_cast<Function *>(v) )
{
op_ir += "@"+v->get_name();
}
else if ( dynamic_cast<Constant *>(v))
{
op_ir += v->print();
}
else
{
op_ir += "%"+v->get_name();
}
return op_ir;
}
std::string print_cmp_type( CmpInst::CmpOp op )
{
switch (op)
{
case CmpInst::GE:
return "sge";
break;
case CmpInst::GT:
return "sgt";
break;
case CmpInst::LE:
return "sle";
break;
case CmpInst::LT:
return "slt";
break;
case CmpInst::EQ:
return "eq";
break;
case CmpInst::NE:
return "ne";
break;
default:
break;
}
return "wrong cmpop";
}
std::string print_fcmp_type( FCmpInst::CmpOp op )
{
switch (op)
{
case FCmpInst::GE:
return "uge";
break;
case FCmpInst::GT:
return "ugt";
break;
case FCmpInst::LE:
return "ule";
break;
case FCmpInst::LT:
return "ult";
break;
case FCmpInst::EQ:
return "ueq";
break;
case FCmpInst::NE:
return "une";
break;
default:
break;
}
return "wrong fcmpop";
}
Loading…
Cancel
Save