[llvm-commits] [llvm] r49562 - in /llvm/branches/ggreif/use-diet: include/llvm/GlobalVariable.h include/llvm/Instructions.h include/llvm/OperandTraits.h lib/VMCore/Globals.cpp lib/VMCore/Instructions.cpp
Gabor Greif
ggreif at gmail.com
Fri Apr 11 15:03:41 PDT 2008
Author: ggreif
Date: Fri Apr 11 17:03:41 2008
New Revision: 49562
URL: http://llvm.org/viewvc/llvm-project?rev=49562&view=rev
Log:
fix allocation layout of GlobalVariable (it may change 0 -> 1 Uses) by introduceing new traits class. detabify.
Modified:
llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h
llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h
llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp
llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h?rev=49562&r1=49561&r2=49562&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Fri Apr 11 17:03:41 2008
@@ -63,9 +63,9 @@
Constant *Initializer = 0, const std::string &Name = "",
Module *Parent = 0, bool ThreadLocal = false,
unsigned AddressSpace = 0) {
- return new (!!Initializer) GlobalVariable(Ty, isConstant, Linkage,
- Initializer, Name, Parent,
- ThreadLocal, AddressSpace);
+ return new (1) GlobalVariable(Ty, isConstant, Linkage,
+ Initializer, Name, Parent,
+ ThreadLocal, AddressSpace);
}
/// GlobalVariable creator - This creates a global and inserts it before the
@@ -74,9 +74,9 @@
Constant *Initializer, const std::string &Name,
GlobalVariable *InsertBefore, bool ThreadLocal = false,
unsigned AddressSpace = 0) {
- return new (!!Initializer) GlobalVariable(Ty, isConstant, Linkage,
- Initializer, Name, InsertBefore,
- ThreadLocal, AddressSpace);
+ return new (1) GlobalVariable(Ty, isConstant, Linkage,
+ Initializer, Name, InsertBefore,
+ ThreadLocal, AddressSpace);
}
/// Provide fast operand accessors
@@ -97,7 +97,7 @@
/// illegal to call this method if the global is external, because we cannot
/// tell what the value is initialized to!
///
- inline Constant *getInitializer() const {
+ inline /*const FIXME*/ Constant *getInitializer() const {
assert(hasInitializer() && "GV doesn't have initializer!");
return static_cast<Constant*>(Op<0>().get());
}
@@ -160,7 +160,7 @@
};
template <>
-struct OperandTraits<GlobalVariable> : VariadicOperandTraits<> {
+struct OperandTraits<GlobalVariable> : OptionalOperandTraits<> {
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalVariable, Value)
Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49562&r1=49561&r2=49562&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Fri Apr 11 17:03:41 2008
@@ -329,7 +329,7 @@
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
- /* Value *getOperand(unsigned i) const {
+ /* Value *getOperand(unsigned i) const {
assert(i < 2 && "getOperand() out of range!");
return OperandList[i];
}
@@ -1353,7 +1353,7 @@
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
- /* const Value *getOperand(unsigned i) const {
+ /* const Value *getOperand(unsigned i) const {
assert(i < 3 && "getOperand() out of range!");
return OperandList[i];
}
Modified: llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h?rev=49562&r1=49561&r2=49562&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/OperandTraits.h Fri Apr 11 17:03:41 2008
@@ -48,6 +48,17 @@
};
//===----------------------------------------------------------------------===//
+// OptionalOperands Trait Class
+//===----------------------------------------------------------------------===//
+
+template <unsigned ARITY = 1>
+struct OptionalOperandTraits : FixedNumOperandTraits<ARITY> {
+ static unsigned operands(const User *U) {
+ return U->getNumOperands();
+ }
+};
+
+//===----------------------------------------------------------------------===//
// VariadicOperand Trait Class
//===----------------------------------------------------------------------===//
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp?rev=49562&r1=49561&r2=49562&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp Fri Apr 11 17:03:41 2008
@@ -89,7 +89,7 @@
Module *ParentModule, bool ThreadLocal,
unsigned AddressSpace)
: GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal,
- OperandTraits<GlobalVariable>::op_end(this) - (InitVal != 0),
+ OperandTraits<GlobalVariable>::op_begin(this),
InitVal != 0, Link, Name),
isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) {
if (InitVal) {
@@ -109,7 +109,7 @@
GlobalVariable *Before, bool ThreadLocal,
unsigned AddressSpace)
: GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal,
- OperandTraits<GlobalVariable>::op_end(this) - (InitVal != 0),
+ OperandTraits<GlobalVariable>::op_begin(this),
InitVal != 0, Link, Name),
isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) {
if (InitVal) {
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49562&r1=49561&r2=49562&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Fri Apr 11 17:03:41 2008
@@ -885,9 +885,9 @@
StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)
: Instruction(Type::VoidTy, Store,
- OperandTraits<StoreInst>::op_begin(this),
- OperandTraits<StoreInst>::operands(this),
- InsertBefore) {
+ OperandTraits<StoreInst>::op_begin(this),
+ OperandTraits<StoreInst>::operands(this),
+ InsertBefore) {
Op<0>().init(val, this);
Op<1>().init(addr, this);
setVolatile(false);
@@ -897,9 +897,9 @@
StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd)
: Instruction(Type::VoidTy, Store,
- OperandTraits<StoreInst>::op_begin(this),
- OperandTraits<StoreInst>::operands(this),
- InsertAtEnd) {
+ OperandTraits<StoreInst>::op_begin(this),
+ OperandTraits<StoreInst>::operands(this),
+ InsertAtEnd) {
Op<0>().init(val, this);
Op<1>().init(addr, this);
setVolatile(false);
@@ -910,9 +910,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
Instruction *InsertBefore)
: Instruction(Type::VoidTy, Store,
- OperandTraits<StoreInst>::op_begin(this),
- OperandTraits<StoreInst>::operands(this),
- InsertBefore) {
+ OperandTraits<StoreInst>::op_begin(this),
+ OperandTraits<StoreInst>::operands(this),
+ InsertBefore) {
Op<0>().init(val, this);
Op<1>().init(addr, this);
setVolatile(isVolatile);
@@ -923,9 +923,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
unsigned Align, Instruction *InsertBefore)
: Instruction(Type::VoidTy, Store,
- OperandTraits<StoreInst>::op_begin(this),
- OperandTraits<StoreInst>::operands(this),
- InsertBefore) {
+ OperandTraits<StoreInst>::op_begin(this),
+ OperandTraits<StoreInst>::operands(this),
+ InsertBefore) {
Op<0>().init(val, this);
Op<1>().init(addr, this);
setVolatile(isVolatile);
@@ -936,9 +936,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
unsigned Align, BasicBlock *InsertAtEnd)
: Instruction(Type::VoidTy, Store,
- OperandTraits<StoreInst>::op_begin(this),
- OperandTraits<StoreInst>::operands(this),
- InsertAtEnd) {
+ OperandTraits<StoreInst>::op_begin(this),
+ OperandTraits<StoreInst>::operands(this),
+ InsertAtEnd) {
Op<0>().init(val, this);
Op<1>().init(addr, this);
setVolatile(isVolatile);
@@ -949,9 +949,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
BasicBlock *InsertAtEnd)
: Instruction(Type::VoidTy, Store,
- OperandTraits<StoreInst>::op_begin(this),
- OperandTraits<StoreInst>::operands(this),
- InsertAtEnd) {
+ OperandTraits<StoreInst>::op_begin(this),
+ OperandTraits<StoreInst>::operands(this),
+ InsertAtEnd) {
Op<0>().init(val, this);
Op<1>().init(addr, this);
setVolatile(isVolatile);
@@ -1239,9 +1239,9 @@
//===----------------------------------------------------------------------===//
ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)
- : Instruction(SV.getType(), ShuffleVector,
- OperandTraits<ShuffleVectorInst>::op_begin(this),
- OperandTraits<ShuffleVectorInst>::operands(this)) {
+ : Instruction(SV.getType(), ShuffleVector,
+ OperandTraits<ShuffleVectorInst>::op_begin(this),
+ OperandTraits<ShuffleVectorInst>::operands(this)) {
Op<0>().init(SV.Op<0>(), this);
Op<1>().init(SV.Op<1>(), this);
Op<2>().init(SV.Op<2>(), this);
@@ -1251,9 +1251,9 @@
const std::string &Name,
Instruction *InsertBefore)
: Instruction(V1->getType(), ShuffleVector,
- OperandTraits<ShuffleVectorInst>::op_begin(this),
- OperandTraits<ShuffleVectorInst>::operands(this),
- InsertBefore) {
+ OperandTraits<ShuffleVectorInst>::op_begin(this),
+ OperandTraits<ShuffleVectorInst>::operands(this),
+ InsertBefore) {
assert(isValidOperands(V1, V2, Mask) &&
"Invalid shuffle vector instruction operands!");
Op<0>().init(V1, this);
@@ -1266,9 +1266,9 @@
const std::string &Name,
BasicBlock *InsertAtEnd)
: Instruction(V1->getType(), ShuffleVector,
- OperandTraits<ShuffleVectorInst>::op_begin(this),
- OperandTraits<ShuffleVectorInst>::operands(this),
- InsertAtEnd) {
+ OperandTraits<ShuffleVectorInst>::op_begin(this),
+ OperandTraits<ShuffleVectorInst>::operands(this),
+ InsertAtEnd) {
assert(isValidOperands(V1, V2, Mask) &&
"Invalid shuffle vector instruction operands!");
More information about the llvm-commits
mailing list