Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/IR/Constants.cpp
Show First 20 Lines • Show All 2,349 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool ConstantExpr::isSupportedBinOp(unsigned Opcode) { | bool ConstantExpr::isSupportedBinOp(unsigned Opcode) { | ||||
switch (Opcode) { | switch (Opcode) { | ||||
case Instruction::UDiv: | case Instruction::UDiv: | ||||
case Instruction::SDiv: | case Instruction::SDiv: | ||||
case Instruction::URem: | case Instruction::URem: | ||||
case Instruction::SRem: | case Instruction::SRem: | ||||
case Instruction::FAdd: | |||||
case Instruction::FSub: | |||||
case Instruction::FMul: | |||||
case Instruction::FDiv: | |||||
case Instruction::FRem: | |||||
return false; | return false; | ||||
case Instruction::Add: | case Instruction::Add: | ||||
case Instruction::Sub: | case Instruction::Sub: | ||||
case Instruction::Mul: | case Instruction::Mul: | ||||
case Instruction::Shl: | case Instruction::Shl: | ||||
case Instruction::LShr: | case Instruction::LShr: | ||||
case Instruction::AShr: | case Instruction::AShr: | ||||
case Instruction::And: | case Instruction::And: | ||||
case Instruction::Or: | case Instruction::Or: | ||||
case Instruction::Xor: | case Instruction::Xor: | ||||
case Instruction::FAdd: | |||||
case Instruction::FSub: | |||||
case Instruction::FMul: | |||||
case Instruction::FDiv: | |||||
case Instruction::FRem: | |||||
return true; | return true; | ||||
default: | default: | ||||
llvm_unreachable("Argument must be binop opcode"); | llvm_unreachable("Argument must be binop opcode"); | ||||
} | } | ||||
} | } | ||||
Constant *ConstantExpr::getSizeOf(Type* Ty) { | Constant *ConstantExpr::getSizeOf(Type* Ty) { | ||||
// sizeof is implemented as: (i64) gep (Ty*)null, 1 | // sizeof is implemented as: (i64) gep (Ty*)null, 1 | ||||
▲ Show 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | |||||
Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2, | Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2, | ||||
bool HasNUW, bool HasNSW) { | bool HasNUW, bool HasNSW) { | ||||
unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) | | unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) | | ||||
(HasNSW ? OverflowingBinaryOperator::NoSignedWrap : 0); | (HasNSW ? OverflowingBinaryOperator::NoSignedWrap : 0); | ||||
return get(Instruction::Add, C1, C2, Flags); | return get(Instruction::Add, C1, C2, Flags); | ||||
} | } | ||||
Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2) { | |||||
return get(Instruction::FAdd, C1, C2); | |||||
} | |||||
Constant *ConstantExpr::getSub(Constant *C1, Constant *C2, | Constant *ConstantExpr::getSub(Constant *C1, Constant *C2, | ||||
bool HasNUW, bool HasNSW) { | bool HasNUW, bool HasNSW) { | ||||
unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) | | unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) | | ||||
(HasNSW ? OverflowingBinaryOperator::NoSignedWrap : 0); | (HasNSW ? OverflowingBinaryOperator::NoSignedWrap : 0); | ||||
return get(Instruction::Sub, C1, C2, Flags); | return get(Instruction::Sub, C1, C2, Flags); | ||||
} | } | ||||
Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2) { | |||||
return get(Instruction::FSub, C1, C2); | |||||
} | |||||
Constant *ConstantExpr::getMul(Constant *C1, Constant *C2, | Constant *ConstantExpr::getMul(Constant *C1, Constant *C2, | ||||
bool HasNUW, bool HasNSW) { | bool HasNUW, bool HasNSW) { | ||||
unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) | | unsigned Flags = (HasNUW ? OverflowingBinaryOperator::NoUnsignedWrap : 0) | | ||||
(HasNSW ? OverflowingBinaryOperator::NoSignedWrap : 0); | (HasNSW ? OverflowingBinaryOperator::NoSignedWrap : 0); | ||||
return get(Instruction::Mul, C1, C2, Flags); | return get(Instruction::Mul, C1, C2, Flags); | ||||
} | } | ||||
Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) { | |||||
return get(Instruction::FMul, C1, C2); | |||||
} | |||||
Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2) { | |||||
return get(Instruction::FDiv, C1, C2); | |||||
} | |||||
Constant *ConstantExpr::getFRem(Constant *C1, Constant *C2) { | |||||
return get(Instruction::FRem, C1, C2); | |||||
} | |||||
Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2) { | Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2) { | ||||
return get(Instruction::And, C1, C2); | return get(Instruction::And, C1, C2); | ||||
} | } | ||||
Constant *ConstantExpr::getOr(Constant *C1, Constant *C2) { | Constant *ConstantExpr::getOr(Constant *C1, Constant *C2) { | ||||
return get(Instruction::Or, C1, C2); | return get(Instruction::Or, C1, C2); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 798 Lines • Show Last 20 Lines |