[llvm-commits] [gcc-plugin] r76226 - in /gcc-plugin/trunk: bits_and_bobs.h llvm-types.cpp
Duncan Sands
baldrick at free.fr
Fri Jul 17 13:23:47 PDT 2009
Author: baldrick
Date: Fri Jul 17 15:23:47 2009
New Revision: 76226
URL: http://llvm.org/viewvc/llvm-project?rev=76226&view=rev
Log:
Move headers around and move the GET/SET_TYPE_LLVM
stuff to a set of external declarations (they will
need to be implemented differently). This gets
llvm-types close to compiling.
Modified:
gcc-plugin/trunk/bits_and_bobs.h
gcc-plugin/trunk/llvm-types.cpp
Modified: gcc-plugin/trunk/bits_and_bobs.h
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/bits_and_bobs.h?rev=76226&r1=76225&r2=76226&view=diff
==============================================================================
--- gcc-plugin/trunk/bits_and_bobs.h (original)
+++ gcc-plugin/trunk/bits_and_bobs.h Fri Jul 17 15:23:47 2009
@@ -19,6 +19,18 @@
#define DECL_LLVM_IF_SET(NODE) \
(DECL_LLVM_SET_P (NODE) ? DECL_LLVM (NODE) : NULL)
+// GET_TYPE_LLVM/SET_TYPE_LLVM - Associate an LLVM type with each TREE type.
+// These are lazily computed by ConvertType.
+
+extern const Type *llvm_set_type(tree Tr, const Type *Ty);
+
+#define SET_TYPE_LLVM(NODE, TYPE) (const Type *)llvm_set_type(NODE, TYPE)
+
+extern const Type *llvm_get_type(unsigned Index);
+
+#define GET_TYPE_LLVM(NODE) \
+ (const Type *)llvm_get_type( 0 )
+
// emit_global_to_llvm - Emit the specified VAR_DECL to LLVM as a global
// variable.
// FIXME: Should not be here
Modified: gcc-plugin/trunk/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-types.cpp?rev=76226&r1=76225&r2=76226&view=diff
==============================================================================
--- gcc-plugin/trunk/llvm-types.cpp (original)
+++ gcc-plugin/trunk/llvm-types.cpp Fri Jul 17 15:23:47 2009
@@ -23,7 +23,7 @@
// This is the code that converts GCC tree types into LLVM types.
//===----------------------------------------------------------------------===//
-#include "llvm-internal.h"
+// LLVM headers
#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
@@ -35,16 +35,22 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/raw_ostream.h"
+
+// System headers
#include <map>
+
+// GCC headers
#undef VISIBILITY_HIDDEN
+#define IN_GCC
-extern "C" {
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tree.h"
-}
+
+// Plugin headers
#include "llvm-abi.h"
+#include "bits_and_bobs.h"
//===----------------------------------------------------------------------===//
// Matching LLVM types with GCC trees
@@ -64,53 +70,6 @@
static LLVMContext &Context = getGlobalContext();
-// GET_TYPE_LLVM/SET_TYPE_LLVM - Associate an LLVM type with each TREE type.
-// These are lazily computed by ConvertType.
-
-#define SET_TYPE_SYMTAB_LLVM(NODE, index) \
- (TYPE_CHECK (NODE)->type.symtab.llvm = index)
-
-// Note down LLVM type for GCC tree node.
-static const Type * llvm_set_type(tree Tr, const Type *Ty) {
-
- // For x86 long double, llvm records the size of the data (80) while
- // gcc's TYPE_SIZE including alignment padding. getTypeAllocSizeInBits
- // is used to compensate for this.
- assert((!TYPE_SIZE(Tr) || !Ty->isSized() || !isInt64(TYPE_SIZE(Tr), true) ||
- getInt64(TYPE_SIZE(Tr), true) ==
- getTargetData().getTypeAllocSizeInBits(Ty))
- && "LLVM type size doesn't match GCC type size!");
-
- unsigned &TypeSlot = LTypesMap[Ty];
- if (TypeSlot) {
- // Already in map.
- SET_TYPE_SYMTAB_LLVM(Tr, TypeSlot);
- return Ty;
- }
-
- unsigned Index = LTypes.size() + 1;
- LTypes.push_back(Ty);
- SET_TYPE_SYMTAB_LLVM(Tr, Index);
- LTypesMap[Ty] = Index;
-
- return Ty;
-}
-
-#define SET_TYPE_LLVM(NODE, TYPE) (const Type *)llvm_set_type(NODE, TYPE)
-
-// Get LLVM Type for the GCC tree node based on LTypes vector index.
-// When GCC tree node is initialized, it has 0 as the index value. This is
-// why all recorded indexes are offset by 1.
-extern "C" const Type *llvm_get_type(unsigned Index) {
- if (Index == 0)
- return NULL;
- assert ((Index - 1) < LTypes.size() && "Invalid LLVM Type index");
- return LTypes[Index - 1];
-}
-
-#define GET_TYPE_LLVM(NODE) \
- (const Type *)llvm_get_type( TYPE_CHECK (NODE)->type.symtab.llvm)
-
// Erase type from LTypes vector
static void llvmEraseLType(const Type *Ty) {
More information about the llvm-commits
mailing list