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

Unified Diff: src/IceTranslator.h

Issue 361733002: Update Subzero to start parsing PNaCl bitcode files. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix more nits. Created 6 years, 6 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
Index: src/IceTranslator.h
diff --git a/src/IceTranslator.h b/src/IceTranslator.h
new file mode 100644
index 0000000000000000000000000000000000000000..345207c750d90532670eac2df195779d296bfca5
--- /dev/null
+++ b/src/IceTranslator.h
@@ -0,0 +1,64 @@
+//===- subzero/src/IceTranslator.h - Translate IR to ICE --------*- 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 the general driver class for translating IR to ICE.
jvoung (off chromium) 2014/07/01 17:32:52 Clarify what IR to ICE? I guess it has to be seria
Karl 2014/07/01 21:31:06 Rewrote this to try and be more clear.
jvoung (off chromium) 2014/07/02 17:00:15 For this one-line summary, it feels like this clas
Karl 2014/07/02 18:09:54 Good point. Fixing.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SUBZERO_SRC_ICETRANSLATOR_H
+#define SUBZERO_SRC_ICETRANSLATOR_H
+
+#include "IceCfg.h"
+#include "IceClFlags.h"
+#include "IceGlobalContext.h"
jvoung (off chromium) 2014/07/01 17:32:52 Could probably fwd declare the IceGlobalContext cl
Karl 2014/07/01 21:31:06 Removing unnecessary includes.
+#include "llvm/ADT/OwningPtr.h"
+
+namespace Ice {
+
+// Base class for translating IR to ICE. The input IR is handled by
+// derived classes. This code assumes that derived classes define one
+// (or more) methods to translate the input IR. Whenever a function is
+// converted to ICE, these methods call translateFcn to finish the
+// translation.
+class Translator {
+public:
+ Translator(Ice::GlobalContext *Ctx, Ice::ClFlags &Flags)
+ : Ctx(Ctx),
+ Flags(Flags),
+ ExitStatus(0) {}
+
+ ~Translator();
+
+protected:
+ Ice::GlobalContext *Ctx;
+ Ice::ClFlags &Flags;
+ // The exit status of the translation. 0 is successful. Nonzero
+ // otherwise.
+ int ExitStatus;
+ // Ideally, Func would be inside the methods that converts IR to
+ // functions. However, emitting the constant pool requires a valid
+ // Cfg object, so we need to defer deleting the last non-empty Cfg
+ // object to emit the constant pool (via emitConstants). TODO:
+ // Since all constants are globally pooled in the Ice::GlobalContext
+ // object, change all Ice::Constant related functions to use
+ // GlobalContext instead of Cfg, and then make emitConstantPool use
+ // that.
+ llvm::OwningPtr<Ice::Cfg> Func;
+
+ /// Translates the constructed ICE function Fcn to machine code.
+ /// Note: As a side effect, Field Func is set to Fcn.
+ void translateFcn(Ice::Cfg *Fcn);
+
+ /// Emits the constant pool.
+ void emitConstants();
+};
+
+}
+
+#endif // SUBZERO_SRC_ICETRANSLATOR_H

Powered by Google App Engine
This is Rietveld 408576698