构建IR打印器,llvm风格,跑通大部分样例(9/10),待修复
This commit is contained in:
@@ -1106,7 +1106,7 @@ public:
|
||||
return make_range(std::next(operand_begin()), operand_end());
|
||||
}
|
||||
Value* getIndex(int index) const { return getOperand(index + 1); }
|
||||
std::list<Value *> getAncestorIndices() const {
|
||||
std::list<Value *> getAncestorIndices() const {
|
||||
std::list<Value *> indices;
|
||||
for (const auto &index : getIndices()) {
|
||||
indices.emplace_back(index->getValue());
|
||||
|
||||
29
src/include/SysYIRPrinter.h
Normal file
29
src/include/SysYIRPrinter.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "IR.h"
|
||||
|
||||
namespace sysy {
|
||||
|
||||
class SysYPrinter {
|
||||
private:
|
||||
Module *pModule;
|
||||
|
||||
public:
|
||||
explicit SysYPrinter(Module *pModule) : pModule(pModule) {}
|
||||
|
||||
public:
|
||||
void printIR();
|
||||
void printGlobalVariable();
|
||||
void printFunction(Function *function);
|
||||
void printInst(Instruction *pInst);
|
||||
void printType(Type *type);
|
||||
void printValue(Value *value);
|
||||
|
||||
public:
|
||||
static std::string getOperandName(Value *operand);
|
||||
std::string getTypeString(Type *type);
|
||||
std::string getValueName(Value *value);
|
||||
};
|
||||
|
||||
} // namespace sysy
|
||||
Reference in New Issue
Block a user