[llvm-commits] [dragonegg] r137455 - in /dragonegg/trunk: include/dragonegg/Trees.h src/Backend.cpp src/Constants.cpp src/Convert.cpp src/Debug.cpp src/Trees.cpp src/Types.cpp
Duncan Sands
baldrick at free.fr
Fri Aug 12 06:07:33 PDT 2011
Author: baldrick
Date: Fri Aug 12 08:07:33 2011
New Revision: 137455
URL: http://llvm.org/viewvc/llvm-project?rev=137455&view=rev
Log:
Move a few trivial functions to inline functions in a header.
No functionality change.
Modified:
dragonegg/trunk/include/dragonegg/Trees.h
dragonegg/trunk/src/Backend.cpp
dragonegg/trunk/src/Constants.cpp
dragonegg/trunk/src/Convert.cpp
dragonegg/trunk/src/Debug.cpp
dragonegg/trunk/src/Trees.cpp
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Trees.h?rev=137455&r1=137454&r2=137455&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Trees.h (original)
+++ dragonegg/trunk/include/dragonegg/Trees.h Fri Aug 12 08:07:33 2011
@@ -23,50 +23,57 @@
#ifndef DRAGONEGG_TREES_H
#define DRAGONEGG_TREES_H
-// LLVM headers
-#include "llvm/ADT/APInt.h"
+// IMPORTANT: ONLY INCLUDE GCC HEADERS IN THIS FILE! ONLY INCLUDE THIS HEADER
+// AMONGST THE STANDARD GCC HEADERS!
-// System headers
-#include <string>
-
-union tree_node;
+// This is the only dragonegg header that is allowed to include GCC headers.
+// As GCC headers poison standard C library routines like malloc, including
+// one before an LLVM or system header may break the build. This is why GCC
+// headers (and this one, as it may include GCC headers) are always included
+// last.
/// getDescriptiveName - Return a helpful name for the given tree, or an empty
/// string if no sensible name was found. These names are used to make the IR
/// more readable, and have no official status.
-std::string getDescriptiveName(union tree_node *t);
+std::string getDescriptiveName(tree t);
/// hasNUW - Return whether overflowing unsigned operations on this type result
/// in undefined behaviour.
-bool hasNUW(tree_node *type);
+inline bool hasNUW(tree type) {
+ return TYPE_UNSIGNED(type) && TYPE_OVERFLOW_UNDEFINED(type);
+}
/// hasNSW - Return whether overflowing signed operations on this type result
/// in undefined behaviour.
-bool hasNSW(tree_node *type);
+inline bool hasNSW(tree type) {
+ return !TYPE_UNSIGNED(type) && TYPE_OVERFLOW_UNDEFINED(type);
+}
/// getIntegerValue - Return the specified INTEGER_CST as an APInt.
-llvm::APInt getIntegerValue(tree_node *exp);
+llvm::APInt getIntegerValue(tree exp);
/// isInt64 - Return true if t is an INTEGER_CST that fits in a 64 bit integer.
/// If Unsigned is false, returns whether it fits in a int64_t. If Unsigned is
/// true, returns whether the value is non-negative and fits in a uint64_t.
/// Always returns false for overflowed constants or if t is NULL.
-bool isInt64(tree_node *t, bool Unsigned);
+bool isInt64(tree t, bool Unsigned);
/// getInt64 - Extract the value of an INTEGER_CST as a 64 bit integer. If
/// Unsigned is false, the value must fit in a int64_t. If Unsigned is true,
/// the value must be non-negative and fit in a uint64_t. Must not be used on
/// overflowed constants. These conditions can be checked by calling isInt64.
-uint64_t getInt64(tree_node *t, bool Unsigned);
+uint64_t getInt64(tree t, bool Unsigned);
/// OffsetIsLLVMCompatible - Return true if the given field is offset from the
/// start of the record by a constant amount which is not humongously big.
-extern bool OffsetIsLLVMCompatible(tree_node *field_decl);
+inline bool OffsetIsLLVMCompatible(tree field_decl) {
+ return isInt64(DECL_FIELD_OFFSET(field_decl), true);
+}
/// getFieldOffsetInBits - Return the bit offset of a FIELD_DECL in a structure.
-extern uint64_t getFieldOffsetInBits(tree_node *field);
+uint64_t getFieldOffsetInBits(tree field);
/// isBitfield - Returns whether to treat the specified field as a bitfield.
-bool isBitfield(tree_node *field_decl);
+bool isBitfield(tree field_decl);
#endif /* DRAGONEGG_TREES_H */
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=137455&r1=137454&r2=137455&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Fri Aug 12 08:07:33 2011
@@ -27,7 +27,6 @@
#include "dragonegg/Debug.h"
#include "dragonegg/OS.h"
#include "dragonegg/Target.h"
-#include "dragonegg/Trees.h"
#include "dragonegg/Types.h"
// LLVM headers
@@ -77,6 +76,9 @@
#include "version.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
#if (GCC_MAJOR != 4)
#error Unsupported GCC major version
#endif
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=137455&r1=137454&r2=137455&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Fri Aug 12 08:07:33 2011
@@ -24,7 +24,6 @@
#include "dragonegg/Cache.h"
#include "dragonegg/Constants.h"
#include "dragonegg/Internals.h"
-#include "dragonegg/Trees.h"
#include "dragonegg/Types.h"
#include "dragonegg/ADT/IntervalList.h"
#include "dragonegg/ADT/Range.h"
@@ -53,6 +52,9 @@
#include "tm_p.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
using namespace llvm;
static LLVMContext &Context = getGlobalContext();
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=137455&r1=137454&r2=137455&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Fri Aug 12 08:07:33 2011
@@ -25,7 +25,6 @@
#include "dragonegg/ABI.h"
#include "dragonegg/Constants.h"
#include "dragonegg/Debug.h"
-#include "dragonegg/Trees.h"
#include "dragonegg/Types.h"
// LLVM headers
@@ -76,6 +75,9 @@
#endif
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
static LLVMContext &Context = getGlobalContext();
STATISTIC(NumBasicBlocks, "Number of basic blocks converted");
Modified: dragonegg/trunk/src/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Debug.cpp?rev=137455&r1=137454&r2=137455&view=diff
==============================================================================
--- dragonegg/trunk/src/Debug.cpp (original)
+++ dragonegg/trunk/src/Debug.cpp Fri Aug 12 08:07:33 2011
@@ -23,7 +23,6 @@
// Plugin headers
#include "dragonegg/Debug.h"
-#include "dragonegg/Trees.h"
// LLVM headers
#include "llvm/Module.h"
@@ -48,6 +47,9 @@
#include "version.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
using namespace llvm;
using namespace llvm::dwarf;
Modified: dragonegg/trunk/src/Trees.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Trees.cpp?rev=137455&r1=137454&r2=137455&view=diff
==============================================================================
--- dragonegg/trunk/src/Trees.cpp (original)
+++ dragonegg/trunk/src/Trees.cpp Fri Aug 12 08:07:33 2011
@@ -20,10 +20,8 @@
// This file defines utility functions for working with GCC trees.
//===----------------------------------------------------------------------===//
-// Plugin headers
-#include "dragonegg/Trees.h"
-
// LLVM headers
+#include "llvm/ADT/APInt.h"
#include "llvm/ADT/Twine.h"
// System headers
@@ -42,6 +40,9 @@
#include "flags.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
using namespace llvm;
/// concatIfNotEmpty - Concatenate the given strings if they are both non-empty.
@@ -130,18 +131,6 @@
return std::string();
}
-/// hasNUW - Return whether overflowing unsigned operations on this type result
-/// in undefined behaviour.
-bool hasNUW(tree type) {
- return TYPE_UNSIGNED(type) && TYPE_OVERFLOW_UNDEFINED(type);
-}
-
-/// hasNSW - Return whether overflowing signed operations on this type result
-/// in undefined behaviour.
-bool hasNSW(tree type) {
- return !TYPE_UNSIGNED(type) && TYPE_OVERFLOW_UNDEFINED(type);
-}
-
/// getIntegerValue - Return the specified INTEGER_CST as an APInt.
APInt getIntegerValue(tree exp) {
double_int val = tree_to_double_int(exp);
@@ -195,12 +184,6 @@
}
}
-/// OffsetIsLLVMCompatible - Return true if the given field is offset from the
-/// start of the record by a constant amount which is not humongously big.
-bool OffsetIsLLVMCompatible(tree field_decl) {
- return isInt64(DECL_FIELD_OFFSET(field_decl), true);
-}
-
/// getFieldOffsetInBits - Return the bit offset of a FIELD_DECL in a structure.
uint64_t getFieldOffsetInBits(tree field) {
assert(OffsetIsLLVMCompatible(field) && "Offset is not constant!");
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=137455&r1=137454&r2=137455&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Fri Aug 12 08:07:33 2011
@@ -24,7 +24,6 @@
// Plugin headers
#include "dragonegg/ABI.h"
#include "dragonegg/Cache.h"
-#include "dragonegg/Trees.h"
#include "dragonegg/Types.h"
// LLVM headers
@@ -51,6 +50,9 @@
#include "tree.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
static LLVMContext &Context = getGlobalContext();
/// SCCInProgress - Set of mutually dependent types currently being converted.
More information about the llvm-commits
mailing list