diff --git a/src/include/midend/IR.h b/src/include/midend/IR.h index 11ccd55..469b050 100644 --- a/src/include/midend/IR.h +++ b/src/include/midend/IR.h @@ -727,6 +727,7 @@ class Instruction : public User { kFCmpGE = 0x1UL << 20, kAnd = 0x1UL << 21, kOr = 0x1UL << 22, + // kXor = 0x1UL << 46, // Unary kNeg = 0x1UL << 23, kNot = 0x1UL << 24, @@ -751,8 +752,10 @@ class Instruction : public User { kPhi = 0x1UL << 39, kBitItoF = 0x1UL << 40, kBitFtoI = 0x1UL << 41, - kSra = 0x1UL << 42, - kMulh = 0x1UL << 43 + kSrl = 0x1UL << 42, // 逻辑右移 + kSll = 0x1UL << 43, // 逻辑左移 + kSra = 0x1UL << 44, // 算术右移 + kMulh = 0x1UL << 45 }; protected: @@ -855,6 +858,10 @@ public: return "BitItoF"; case kBitFtoI: return "BitFtoI"; + case kSrl: + return "lshr"; + case kSll: + return "shl"; case kSra: return "ashr"; default: @@ -868,7 +875,7 @@ public: bool isBinary() const { static constexpr uint64_t BinaryOpMask = - (kAdd | kSub | kMul | kDiv | kRem | kAnd | kOr | kSra | kMulh) | + (kAdd | kSub | kMul | kDiv | kRem | kAnd | kOr | kSra | kSrl | kSll | kMulh) | (kICmpEQ | kICmpNE | kICmpLT | kICmpGT | kICmpLE | kICmpGE); return kind & BinaryOpMask; } diff --git a/src/include/midend/IRBuilder.h b/src/include/midend/IRBuilder.h index d08bca3..65a7ac2 100644 --- a/src/include/midend/IRBuilder.h +++ b/src/include/midend/IRBuilder.h @@ -217,7 +217,13 @@ class IRBuilder { BinaryInst * createOrInst(Value *lhs, Value *rhs, const std::string &name = "") { return createBinaryInst(Instruction::kOr, Type::getIntType(), lhs, rhs, name); } ///< 创建按位或指令 - BinaryInst * createSRAInst(Value *lhs, Value *rhs, const std::string &name = "") { + BinaryInst * createSllInst(Value *lhs, Value *rhs, const std::string &name = "") { + return createBinaryInst(Instruction::kSll, Type::getIntType(), lhs, rhs, name); + } ///< 创建逻辑左移指令 + BinaryInst * createSrlInst(Value *lhs, Value *rhs, const std::string &name = "") { + return createBinaryInst(Instruction::kSrl, Type::getIntType(), lhs, rhs, name); + } ///< 创建逻辑右移指令 + BinaryInst * createSraInst(Value *lhs, Value *rhs, const std::string &name = "") { return createBinaryInst(Instruction::kSra, Type::getIntType(), lhs, rhs, name); } ///< 创建算术右移指令 BinaryInst * createMulhInst(Value *lhs, Value *rhs, const std::string &name = "") {