Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(650)

Unified Diff: src/IceGlobalContext.h

Issue 205613002: Initial skeleton of Subzero. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Use non-anonymous structs so that array_lengthof works Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceDefs.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
new file mode 100644
index 0000000000000000000000000000000000000000..9224d899cf449281efb176836bece1af6fc5d166
--- /dev/null
+++ b/src/IceGlobalContext.h
@@ -0,0 +1,85 @@
+//===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares aspects of the compilation that persist across
+// multiple functions.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H
+#define SUBZERO_SRC_ICEGLOBALCONTEXT_H
+
+#include "llvm/ADT/OwningPtr.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "IceDefs.h"
+#include "IceTypes.h"
+
+namespace Ice {
+
+// TODO: Accesses to all non-const fields of GlobalContext need to
+// be synchronized, especially the constant pool, the allocator, and
+// the output streams.
+class GlobalContext {
+public:
+ GlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit,
+ VerboseMask Mask, IceString TestPrefix);
+ ~GlobalContext();
+
+ // Returns true if any of the specified options in the verbose mask
+ // are set. If the argument is omitted, it checks if any verbose
+ // options at all are set. IceV_Timing is treated specially, so
+ // that running with just IceV_Timing verbosity doesn't trigger an
+ // avalanche of extra output.
+ bool isVerbose(VerboseMask Mask = (IceV_All & ~IceV_Timing)) const {
+ return VMask & Mask;
+ }
+ void setVerbose(VerboseMask Mask) { VMask = Mask; }
+ void addVerbose(VerboseMask Mask) { VMask |= Mask; }
+ void subVerbose(VerboseMask Mask) { VMask &= ~Mask; }
+
+ Ostream &getStrDump() { return StrDump; }
+ Ostream &getStrEmit() { return StrEmit; }
+
+ // When emitting assembly, we allow a string to be prepended to
+ // names of translated functions. This makes it easier to create an
+ // execution test against a reference translator like llc, with both
+ // translators using the same bitcode as input.
+ IceString getTestPrefix() const { return TestPrefix; }
+ IceString mangleName(const IceString &Name) const;
+
+ // Manage Constants.
+ // getConstant*() functions are not const because they might add
+ // something to the constant pool.
+ Constant *getConstantInt(Type Ty, uint64_t ConstantInt64);
+ Constant *getConstantFloat(float Value);
+ Constant *getConstantDouble(double Value);
+ // Returns a symbolic constant.
+ Constant *getConstantSym(Type Ty, int64_t Offset, const IceString &Name = "",
+ bool SuppressMangling = false);
+
+ // Allocate data of type T using the global allocator.
+ template <typename T> T *allocate() { return Allocator.Allocate<T>(); }
+
+private:
+ Ostream StrDump; // Stream for dumping / diagnostics
+ Ostream StrEmit; // Stream for code emission
+
+ llvm::BumpPtrAllocator Allocator;
+ VerboseMask VMask;
+ llvm::OwningPtr<class ConstantPool> ConstPool;
+ const IceString TestPrefix;
+ GlobalContext(const GlobalContext &) LLVM_DELETED_FUNCTION;
+ GlobalContext &operator=(const GlobalContext &) LLVM_DELETED_FUNCTION;
+};
+
+} // end of namespace Ice
+
+#endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H
« no previous file with comments | « src/IceDefs.h ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698