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

Side by Side 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: Introduce IceGlobalContext, and rearrange other things around that 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 unified diff | Download patch
OLDNEW
(Empty)
1 //===- subzero/src/IceGlobalContext.h - Global context defs -----*- C++ -*-===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares aspects of the compilation that persist across
11 // multiple functions.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef SUBZERO_SRC_ICEGLOBALCONTEXT_H
16 #define SUBZERO_SRC_ICEGLOBALCONTEXT_H
17
18 #include "llvm/ADT/OwningPtr.h"
19 #include "llvm/Support/Allocator.h"
20 #include "llvm/Support/raw_ostream.h"
21
22 #include "IceDefs.h"
23 #include "IceTypes.h"
24
25 // TODO: Accesses to all non-const fields of IceGlobalContext need to
26 // be synchronized, especially the constant pool, the allocator, and
27 // the output streams.
28 class IceGlobalContext {
29 public:
30 IceGlobalContext(llvm::raw_ostream *OsDump, llvm::raw_ostream *OsEmit,
31 IceVerboseMask VerboseMask, IceString TestPrefix);
32 ~IceGlobalContext();
33
34 // Returns true if any of the specified options in the verbose mask
35 // are set. If the argument is omitted, it checks if any verbose
36 // options at all are set. IceV_Timing is treated specially, so
37 // that running with just IceV_Timing verbosity doesn't trigger an
38 // avalanche of extra output.
39 bool isVerbose(IceVerboseMask Mask = (IceV_All & ~IceV_Timing)) const {
40 return VerboseMask & Mask;
41 }
42 void setVerbose(IceVerboseMask Mask) { VerboseMask = Mask; }
43 void addVerbose(IceVerboseMask Mask) { VerboseMask |= Mask; }
44 void subVerbose(IceVerboseMask Mask) { VerboseMask &= ~Mask; }
45
46 // When emitting assembly, we allow a string to be prepended to
47 // names of translated functions. This makes it easier to create an
48 // execution test against a reference translator like llc, with both
49 // translators using the same bitcode as input.
50 IceString getTestPrefix() const { return TestPrefix; }
51 IceString mangleName(const IceString &Name) const;
52
53 // Manage IceConstants.
54 // getConstant*() functions are not const because they might add
55 // something to the constant pool.
56 IceConstant *getConstantInt(IceType Type, uint64_t ConstantInt64);
57 IceConstant *getConstantFloat(float Value);
58 IceConstant *getConstantDouble(double Value);
59 // Returns a symbolic constant. Handle is currently unused but is
60 // reserved to hold something LLVM-specific to facilitate linking.
JF 2014/04/16 01:27:32 What would handle hold?
Jim Stichnoth 2014/04/21 20:26:40 I can't really say concretely, so I killed this wh
61 IceConstant *getConstantSym(IceType Type, const void *Handle, int64_t Offset,
62 const IceString &Name = "",
63 bool SuppressMangling = false);
64
65 // Allocate data of type T using the global allocator.
66 template <typename T> T *allocate() { return Allocator.Allocate<T>(); }
67
68 IceOstream StrDump; // Stream for dumping / diagnostics
69 IceOstream StrEmit; // Stream for code emission
JF 2014/04/16 01:27:32 Public?
Jim Stichnoth 2014/04/21 20:26:40 Make them private, with public accessor methods.
70
71 private:
72 llvm::BumpPtrAllocator Allocator;
73 IceVerboseMask VerboseMask;
74 llvm::OwningPtr<class IceConstantPool> ConstantPool;
75 const IceString TestPrefix;
76 IceGlobalContext(const IceGlobalContext &) LLVM_DELETED_FUNCTION;
77 IceGlobalContext &operator=(const IceGlobalContext &) LLVM_DELETED_FUNCTION;
78 };
79
80 #endif // SUBZERO_SRC_ICEGLOBALCONTEXT_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698