Chromium Code Reviews| Index: src/IceTranslator.h |
| diff --git a/src/IceTranslator.h b/src/IceTranslator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0c4af132f1f8dd5b1d1c9247d84f5c034d7140dc |
| --- /dev/null |
| +++ b/src/IceTranslator.h |
| @@ -0,0 +1,63 @@ |
| +//===- subzero/src/IceTranslator.h - Translate IR to ICE --------*- C++ -*-===// |
|
jvoung (off chromium)
2014/07/02 22:07:33
Ice to machine code
Karl
2014/07/07 21:50:55
Done.
|
| +// |
| +// 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 ICE to |
| +// machine code. |
| +// |
| +//===----------------------------------------------------------------------===// |
| + |
| +#ifndef SUBZERO_SRC_ICETRANSLATOR_H |
| +#define SUBZERO_SRC_ICETRANSLATOR_H |
| + |
| +#include "llvm/ADT/OwningPtr.h" |
| + |
| +namespace Ice { |
| + |
| +class ClFlags; |
| +class Cfg; |
| +class GlobalContext; |
| + |
| +// Base class for translating ICE to machine code. |
| +// Derived classes convert other intermediate representations down to ICE, |
| +// and then call the appropriate (inherited) methods to convert ICE into |
| +// machine instructions. |
| +class Translator { |
| +public: |
| + Translator(GlobalContext *Ctx, ClFlags &Flags) |
| + : Ctx(Ctx), Flags(Flags), ExitStatus(0) {} |
| + |
| + ~Translator(); |
| + int getExitStatus() const { return ExitStatus; } |
| + |
| +protected: |
| + GlobalContext *Ctx; |
| + ClFlags &Flags; |
| + // The exit status of the translation. 0 is successful. Nonzero |
| + // otherwise. |
| + int ExitStatus; |
|
Jim Stichnoth
2014/07/07 20:50:23
Originally, ExitStatus was an int local variable d
Karl
2014/07/07 21:50:55
Done.
|
| + // 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; |
|
Jim Stichnoth
2014/07/07 20:50:23
Use Cfg instead of Ice::Cfg, here and below.
Karl
2014/07/07 21:50:55
Done.
|
| + |
| + /// 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(); |
| +}; |
|
Jim Stichnoth
2014/07/07 20:50:23
Add private methods:
Translator(const Translato
Karl
2014/07/07 21:50:55
Done.
|
| +} |
| + |
| +#endif // SUBZERO_SRC_ICETRANSLATOR_H |