[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Mar 29 05:21:20 PST 2004


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.82 -> 1.83

---
Log message:

Add a bunch of methods that should have been added a long time ago.


---
Diffs of the changes:  (+61 -0)

Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.82 llvm/lib/VMCore/Constants.cpp:1.83
--- llvm/lib/VMCore/Constants.cpp:1.82	Thu Mar 11 23:54:04 2004
+++ llvm/lib/VMCore/Constants.cpp	Sun Mar 28 20:37:53 2004
@@ -309,6 +309,67 @@
     Operands.push_back(Use(IdxList[i], this));
 }
 
+/// ConstantExpr::get* - Return some common constants without having to
+/// specify the full Instruction::OPCODE identifier.
+///
+Constant *ConstantExpr::getNeg(Constant *C) {
+  return get(Instruction::Sub, getNullValue(C->getType()), C);
+}
+Constant *ConstantExpr::getNot(Constant *C) {
+  assert(isa<ConstantIntegral>(C) && "Cannot NOT a nonintegral type!");
+  return get(Instruction::Xor, C,
+             ConstantIntegral::getAllOnesValue(C->getType()));
+}
+Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2) {
+  return get(Instruction::Add, C1, C2);
+}
+Constant *ConstantExpr::getSub(Constant *C1, Constant *C2) {
+  return get(Instruction::Sub, C1, C2);
+}
+Constant *ConstantExpr::getMul(Constant *C1, Constant *C2) {
+  return get(Instruction::Mul, C1, C2);
+}
+Constant *ConstantExpr::getDiv(Constant *C1, Constant *C2) {
+  return get(Instruction::Div, C1, C2);
+}
+Constant *ConstantExpr::getRem(Constant *C1, Constant *C2) {
+  return get(Instruction::Rem, C1, C2);
+}
+Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2) {
+  return get(Instruction::And, C1, C2);
+}
+Constant *ConstantExpr::getOr(Constant *C1, Constant *C2) {
+  return get(Instruction::Or, C1, C2);
+}
+Constant *ConstantExpr::getXor(Constant *C1, Constant *C2) {
+  return get(Instruction::Xor, C1, C2);
+}
+Constant *ConstantExpr::getSetEQ(Constant *C1, Constant *C2) {
+  return get(Instruction::SetEQ, C1, C2);
+}
+Constant *ConstantExpr::getSetNE(Constant *C1, Constant *C2) {
+  return get(Instruction::SetNE, C1, C2);
+}
+Constant *ConstantExpr::getSetLT(Constant *C1, Constant *C2) {
+  return get(Instruction::SetLT, C1, C2);
+}
+Constant *ConstantExpr::getSetGT(Constant *C1, Constant *C2) {
+  return get(Instruction::SetGT, C1, C2);
+}
+Constant *ConstantExpr::getSetLE(Constant *C1, Constant *C2) {
+  return get(Instruction::SetLE, C1, C2);
+}
+Constant *ConstantExpr::getSetGE(Constant *C1, Constant *C2) {
+  return get(Instruction::SetGE, C1, C2);
+}
+Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) {
+  return get(Instruction::Shl, C1, C2);
+}
+Constant *ConstantExpr::getShr(Constant *C1, Constant *C2) {
+  return get(Instruction::Shr, C1, C2);
+}
+
+
 
 
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list