[midend]增加了指令重命名逻辑。

This commit is contained in:
rain2133
2025-08-06 01:31:23 +08:00
parent 08fcda939b
commit a4406e0112
2 changed files with 214 additions and 13 deletions

View File

@@ -98,7 +98,6 @@ class PointerType : public Type {
public:
Type* getBaseType() const { return baseType; } ///< 获取指向的类型
void print(std::ostream& os) const override;
};
class FunctionType : public Type {
@@ -118,7 +117,6 @@ class FunctionType : public Type {
Type* getReturnType() const { return returnType; } ///< 获取返回值类信息
auto getParamTypes() const { return make_range(paramTypes); } ///< 获取形参类型列表
unsigned getNumParams() const { return paramTypes.size(); } ///< 获取形参数量
void print(std::ostream& os) const override;
};
class ArrayType : public Type {
@@ -135,7 +133,6 @@ class ArrayType : public Type {
: Type(Kind::kArray), elementType(elementType), numElements(numElements) {}
Type *elementType;
unsigned numElements; // 当前维度的大小
void print(std::ostream& os) const override;
};
/*!
@@ -980,16 +977,10 @@ class CallInst : public Instruction {
friend class IRBuilder;
protected:
CallInst(Function *callee, const std::vector<Value *> &args, BasicBlock *parent = nullptr, const std::string &name = "")
: Instruction(kCall, callee->getReturnType(), parent, name) {
addOperand(callee);
for (auto arg : args) {
addOperand(arg);
}
}
CallInst(Function *callee, const std::vector<Value *> &args, BasicBlock *parent = nullptr, const std::string &name = "");
public:
Function *getCallee() const { return dynamic_cast<Function *>(getOperand(0)); }
Function *getCallee() const;
auto getArguments() const {
return make_range(std::next(operand_begin()), operand_end());
}