summaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-22 08:08:12 +0000
committered <ed@FreeBSD.org>2009-06-22 08:08:12 +0000
commita4c19d68f13cf0a83bc0da53bd6d547fcaf635fe (patch)
tree86c1bc482baa6c81fc70b8d715153bfa93377186 /include/llvm/Support
parentdb89e312d968c258aba3c79c1c398f5fb19267a3 (diff)
downloadFreeBSD-src-a4c19d68f13cf0a83bc0da53bd6d547fcaf635fe.zip
FreeBSD-src-a4c19d68f13cf0a83bc0da53bd6d547fcaf635fe.tar.gz
Update LLVM sources to r73879.
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/CommandLine.h4
-rw-r--r--include/llvm/Support/DebugLoc.h101
-rw-r--r--include/llvm/Support/IRBuilder.h8
-rw-r--r--include/llvm/Support/ManagedStatic.h16
-rw-r--r--include/llvm/Support/SourceMgr.h120
5 files changed, 235 insertions, 14 deletions
diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h
index fa3b870..3ae5013 100644
--- a/include/llvm/Support/CommandLine.h
+++ b/include/llvm/Support/CommandLine.h
@@ -539,7 +539,7 @@ template<>
class parser<bool> : public basic_parser<bool> {
const char *ArgStr;
public:
-
+
// parse - Return true on error.
bool parse(Option &O, const char *ArgName, const std::string &Arg, bool &Val);
@@ -1105,7 +1105,7 @@ public:
}
};
-// multi_arg - Modifier to set the number of additional values.
+// multi_val - Modifier to set the number of additional values.
struct multi_val {
unsigned AdditionalVals;
explicit multi_val(unsigned N) : AdditionalVals(N) {}
diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h
new file mode 100644
index 0000000..5c089ef
--- /dev/null
+++ b/include/llvm/Support/DebugLoc.h
@@ -0,0 +1,101 @@
+//===---- llvm/DebugLoc.h - Debug Location Information ----------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines a number of light weight data structures used
+// to describe and track debug location information.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGLOC_H
+#define LLVM_DEBUGLOC_H
+
+#include "llvm/ADT/DenseMap.h"
+#include <vector>
+
+namespace llvm {
+ class GlobalVariable;
+
+ /// DebugLocTuple - Debug location tuple of filename id, line and column.
+ ///
+ struct DebugLocTuple {
+ GlobalVariable *CompileUnit;
+ unsigned Line, Col;
+
+ DebugLocTuple(GlobalVariable *v, unsigned l, unsigned c)
+ : CompileUnit(v), Line(l), Col(c) {};
+
+ bool operator==(const DebugLocTuple &DLT) const {
+ return CompileUnit == DLT.CompileUnit &&
+ Line == DLT.Line && Col == DLT.Col;
+ }
+ bool operator!=(const DebugLocTuple &DLT) const {
+ return !(*this == DLT);
+ }
+ };
+
+ /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
+ /// to index into a vector of unique debug location tuples.
+ class DebugLoc {
+ unsigned Idx;
+
+ public:
+ DebugLoc() : Idx(~0U) {} // Defaults to invalid.
+
+ static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = ~0U; return L; }
+ static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; }
+
+ unsigned getIndex() const { return Idx; }
+
+ /// isUnknown - Return true if there is no debug info for the SDNode /
+ /// MachineInstr.
+ bool isUnknown() const { return Idx == ~0U; }
+
+ bool operator==(const DebugLoc &DL) const { return Idx == DL.Idx; }
+ bool operator!=(const DebugLoc &DL) const { return !(*this == DL); }
+ };
+
+ // Partially specialize DenseMapInfo for DebugLocTyple.
+ template<> struct DenseMapInfo<DebugLocTuple> {
+ static inline DebugLocTuple getEmptyKey() {
+ return DebugLocTuple(0, ~0U, ~0U);
+ }
+ static inline DebugLocTuple getTombstoneKey() {
+ return DebugLocTuple((GlobalVariable*)~1U, ~1U, ~1U);
+ }
+ static unsigned getHashValue(const DebugLocTuple &Val) {
+ return DenseMapInfo<GlobalVariable*>::getHashValue(Val.CompileUnit) ^
+ DenseMapInfo<unsigned>::getHashValue(Val.Line) ^
+ DenseMapInfo<unsigned>::getHashValue(Val.Col);
+ }
+ static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) {
+ return LHS.CompileUnit == RHS.CompileUnit &&
+ LHS.Line == RHS.Line &&
+ LHS.Col == RHS.Col;
+ }
+
+ static bool isPod() { return true; }
+ };
+
+ /// DebugLocTracker - This class tracks debug location information.
+ ///
+ struct DebugLocTracker {
+ /// DebugLocations - A vector of unique DebugLocTuple's.
+ ///
+ std::vector<DebugLocTuple> DebugLocations;
+
+ /// DebugIdMap - This maps DebugLocTuple's to indices into the
+ /// DebugLocations vector.
+ DenseMap<DebugLocTuple, unsigned> DebugIdMap;
+
+ DebugLocTracker() {}
+ };
+
+} // end namespace llvm
+
+#endif /* LLVM_DEBUGLOC_H */
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index 7942de7..ed6a3f1 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -17,6 +17,7 @@
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
+#include "llvm/GlobalAlias.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
#include "llvm/Support/ConstantFolder.h"
@@ -202,7 +203,7 @@ public:
Value *CreateFMul(Value *LHS, Value *RHS, const char *Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
- return Folder.CreateMul(LC, RC);
+ return Folder.CreateFMul(LC, RC);
return Insert(BinaryOperator::CreateFMul(LHS, RHS), Name);
}
Value *CreateUDiv(Value *LHS, Value *RHS, const char *Name = "") {
@@ -291,6 +292,11 @@ public:
return Folder.CreateNeg(VC);
return Insert(BinaryOperator::CreateNeg(V), Name);
}
+ Value *CreateFNeg(Value *V, const char *Name = "") {
+ if (Constant *VC = dyn_cast<Constant>(V))
+ return Folder.CreateFNeg(VC);
+ return Insert(BinaryOperator::CreateFNeg(V), Name);
+ }
Value *CreateNot(Value *V, const char *Name = "") {
if (Constant *VC = dyn_cast<Constant>(V))
return Folder.CreateNot(VC);
diff --git a/include/llvm/Support/ManagedStatic.h b/include/llvm/Support/ManagedStatic.h
index 619cc20..4fc6483 100644
--- a/include/llvm/Support/ManagedStatic.h
+++ b/include/llvm/Support/ManagedStatic.h
@@ -15,6 +15,7 @@
#define LLVM_SUPPORT_MANAGED_STATIC_H
#include "llvm/System/Atomic.h"
+#include "llvm/System/Threading.h"
namespace llvm {
@@ -60,28 +61,28 @@ public:
// Accessors.
C &operator*() {
void* tmp = Ptr;
- sys::MemoryFence();
+ if (llvm_is_multithreaded()) sys::MemoryFence();
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>);
return *static_cast<C*>(Ptr);
}
C *operator->() {
void* tmp = Ptr;
- sys::MemoryFence();
+ if (llvm_is_multithreaded()) sys::MemoryFence();
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>);
return static_cast<C*>(Ptr);
}
const C &operator*() const {
void* tmp = Ptr;
- sys::MemoryFence();
+ if (llvm_is_multithreaded()) sys::MemoryFence();
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>);
return *static_cast<C*>(Ptr);
}
const C *operator->() const {
void* tmp = Ptr;
- sys::MemoryFence();
+ if (llvm_is_multithreaded()) sys::MemoryFence();
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>);
return static_cast<C*>(Ptr);
@@ -94,13 +95,6 @@ public:
void Register() { RegisterManagedStatic(0, CleanupFn); }
};
-
-/// llvm_start_multithreaded - Allocate and initialize structures needed to
-/// make LLVM safe for multithreading. The return value indicates whether
-/// multithreaded initialization succeeded. LLVM will still be operational
-/// on "failed" return, but will not be safe to run multithreaded.
-bool llvm_start_multithreaded();
-
/// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
void llvm_shutdown();
diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h
new file mode 100644
index 0000000..25775cb
--- /dev/null
+++ b/include/llvm/Support/SourceMgr.h
@@ -0,0 +1,120 @@
+//===- SourceMgr.h - Manager for Source Buffers & Diagnostics ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the SourceMgr class. This class is used as a simple
+// substrate for diagnostics, #include handling, and other low level things for
+// simple parsers.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUPPORT_SOURCEMGR_H
+#define SUPPORT_SOURCEMGR_H
+
+#include <string>
+#include <vector>
+#include <cassert>
+
+namespace llvm {
+ class MemoryBuffer;
+ class SourceMgr;
+
+class SMLoc {
+ const char *Ptr;
+public:
+ SMLoc() : Ptr(0) {}
+ SMLoc(const SMLoc &RHS) : Ptr(RHS.Ptr) {}
+
+ bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; }
+ bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; }
+
+ const char *getPointer() const { return Ptr; }
+
+ static SMLoc getFromPointer(const char *Ptr) {
+ SMLoc L;
+ L.Ptr = Ptr;
+ return L;
+ }
+};
+
+/// SourceMgr - This owns the files read by tblgen, handles include stacks,
+/// and handles printing of diagnostics.
+class SourceMgr {
+ struct SrcBuffer {
+ /// Buffer - The memory buffer for the file.
+ MemoryBuffer *Buffer;
+
+ /// IncludeLoc - This is the location of the parent include, or null if at
+ /// the top level.
+ SMLoc IncludeLoc;
+ };
+
+ /// Buffers - This is all of the buffers that we are reading from.
+ std::vector<SrcBuffer> Buffers;
+
+ // IncludeDirectories - This is the list of directories we should search for
+ // include files in.
+ std::vector<std::string> IncludeDirectories;
+
+ SourceMgr(const SourceMgr&); // DO NOT IMPLEMENT
+ void operator=(const SourceMgr&); // DO NOT IMPLEMENT
+public:
+ SourceMgr() {}
+ ~SourceMgr();
+
+ void setIncludeDirs(const std::vector<std::string> &Dirs) {
+ IncludeDirectories = Dirs;
+ }
+
+ const SrcBuffer &getBufferInfo(unsigned i) const {
+ assert(i < Buffers.size() && "Invalid Buffer ID!");
+ return Buffers[i];
+ }
+
+ const MemoryBuffer *getMemoryBuffer(unsigned i) const {
+ assert(i < Buffers.size() && "Invalid Buffer ID!");
+ return Buffers[i].Buffer;
+ }
+
+ SMLoc getParentIncludeLoc(unsigned i) const {
+ assert(i < Buffers.size() && "Invalid Buffer ID!");
+ return Buffers[i].IncludeLoc;
+ }
+
+ unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) {
+ SrcBuffer NB;
+ NB.Buffer = F;
+ NB.IncludeLoc = IncludeLoc;
+ Buffers.push_back(NB);
+ return Buffers.size()-1;
+ }
+
+ /// AddIncludeFile - Search for a file with the specified name in the current
+ /// directory or in one of the IncludeDirs. If no file is found, this returns
+ /// ~0, otherwise it returns the buffer ID of the stacked file.
+ unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc);
+
+ /// FindBufferContainingLoc - Return the ID of the buffer containing the
+ /// specified location, returning -1 if not found.
+ int FindBufferContainingLoc(SMLoc Loc) const;
+
+ /// FindLineNumber - Find the line number for the specified location in the
+ /// specified file. This is not a fast method.
+ unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const;
+
+ /// PrintMessage - Emit a message about the specified location with the
+ /// specified string.
+ void PrintMessage(SMLoc Loc, const std::string &Msg) const;
+
+private:
+ void PrintIncludeStack(SMLoc IncludeLoc) const;
+};
+
+} // end llvm namespace
+
+#endif
OpenPOWER on IntegriCloud