[llvm-commits] [dragonegg] r127880 - /dragonegg/trunk/Constants.cpp
Duncan Sands
baldrick at free.fr
Fri Mar 18 08:51:19 PDT 2011
Author: baldrick
Date: Fri Mar 18 10:51:19 2011
New Revision: 127880
URL: http://llvm.org/viewvc/llvm-project?rev=127880&view=rev
Log:
Cosmetic changes.
Modified:
dragonegg/trunk/Constants.cpp
Modified: dragonegg/trunk/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=127880&r1=127879&r2=127880&view=diff
==============================================================================
--- dragonegg/trunk/Constants.cpp (original)
+++ dragonegg/trunk/Constants.cpp Fri Mar 18 10:51:19 2011
@@ -52,6 +52,10 @@
static LLVMContext &Context = getGlobalContext();
+//===----------------------------------------------------------------------===//
+// ... InterpretAsType ...
+//===----------------------------------------------------------------------===//
+
/// BitSlice - A contiguous range of bits held in memory.
class BitSlice {
int First, Last; // Range [First, Last)
@@ -395,6 +399,11 @@
}
}
+
+//===----------------------------------------------------------------------===//
+// ... ConvertInitializer ...
+//===----------------------------------------------------------------------===//
+
/// EncodeExpr - Write the given expression into Buffer as it would appear in
/// memory on the target (the buffer is resized to contain exactly the bytes
/// written). Return the number of bytes written; this can also be obtained
@@ -1278,6 +1287,11 @@
}
}
+/// ConvertInitializer - Convert the initial value for a global variable to an
+/// equivalent LLVM constant. Also handles constant constructors. The type of
+/// the returned value may be pretty much anything. All that is guaranteed is
+/// that it has the same alloc size as the original expression and has alignment
+/// equal to or less than that of the original expression.
Constant *ConvertInitializer(tree exp) {
assert(TREE_CONSTANT(exp) && "Isn't a constant!");
switch (TREE_CODE(exp)) {
@@ -1304,6 +1318,7 @@
}
}
+
//===----------------------------------------------------------------------===//
// ... AddressOf ...
//===----------------------------------------------------------------------===//
@@ -1430,7 +1445,7 @@
/// AddressOfINDIRECT_REF - Return the address of a dereference.
static Constant *AddressOfINDIRECT_REF(tree exp) {
- // The address is just the operand. Get it as an LLVM constant.
+ // The address is just the dereferenced operand. Get it as an LLVM constant.
Constant *C = ConvertInitializer(TREE_OPERAND(exp, 0));
// Make no assumptions about the type of the constant.
return InterpretAsType(C, ConvertType(TREE_TYPE(TREE_OPERAND(exp, 0))), 0);
@@ -1454,6 +1469,11 @@
return TheTreeToLLVM->AddressOfLABEL_DECL(exp);
}
+/// AddressOf - Given an expression with a constant address such as a constant,
+/// a global variable or a label, returns the address. The type of the returned
+/// is always a pointer type and, as long as 'exp' does not have void type, the
+/// type of the pointee is the memory type that corresponds to the type of exp
+/// (see ConvertType).
Constant *AddressOf(tree exp) {
Constant *Addr;
@@ -1500,5 +1520,6 @@
Ty = Type::getInt8Ty(Context); // void* -> i8*.
else
Ty = ConvertType(TREE_TYPE(exp));
+
return TheFolder->CreateBitCast(Addr, Ty->getPointerTo());
}
More information about the llvm-commits
mailing list