blob: 24a627b246504b0fdc4ae3d70bea263740d3e133 [file] [log] [blame]
Karl Schimpf8d7abae2014-07-07 14:50:30 -07001//===- subzero/src/PNaClTranslator.h - ICE from bitcode ---------*- 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//===----------------------------------------------------------------------===//
Andrew Scull9612d322015-07-06 14:53:25 -07009///
10/// \file
11/// This file declares the PNaCl bitcode file to ICE, to machine code
12/// translator.
13///
Karl Schimpf8d7abae2014-07-07 14:50:30 -070014//===----------------------------------------------------------------------===//
15
16#ifndef SUBZERO_SRC_PNACLTRANSLATOR_H
17#define SUBZERO_SRC_PNACLTRANSLATOR_H
18
Jim Stichnotha18cc9c2014-09-30 19:10:22 -070019#include "IceTranslator.h"
20
John Porto67f8de92015-06-25 10:14:17 -070021#include <string>
22
Karl Schimpf2e7daef2015-01-09 13:04:13 -080023namespace llvm {
24class MemoryBuffer;
Jan Voungc1f07ea2015-03-06 14:53:30 -080025class MemoryObject;
Karl Schimpf2e7daef2015-01-09 13:04:13 -080026} // end of namespace llvm
27
Karl Schimpf8d7abae2014-07-07 14:50:30 -070028namespace Ice {
29
30class PNaClTranslator : public Translator {
Jim Stichnothc6ead202015-02-24 09:30:30 -080031 PNaClTranslator() = delete;
Jim Stichnoth7b451a92014-10-15 14:39:23 -070032 PNaClTranslator(const PNaClTranslator &) = delete;
33 PNaClTranslator &operator=(const PNaClTranslator &) = delete;
34
Karl Schimpf8d7abae2014-07-07 14:50:30 -070035public:
Jim Stichnothc6ead202015-02-24 09:30:30 -080036 explicit PNaClTranslator(GlobalContext *Ctx) : Translator(Ctx) {}
Jim Stichnothf4fbf7f2015-08-08 08:37:02 -070037 ~PNaClTranslator() override = default;
Karl Schimpf2e7daef2015-01-09 13:04:13 -080038
Andrew Scull9612d322015-07-06 14:53:25 -070039 /// Reads the PNaCl bitcode file and translates to ICE, which is then
40 /// converted to machine code. Sets ErrorStatus to 1 if any errors
41 /// occurred. Takes ownership of the MemoryObject.
Jan Voungc1f07ea2015-03-06 14:53:30 -080042 void translate(const std::string &IRFilename,
43 std::unique_ptr<llvm::MemoryObject> &&MemoryObject);
Karl Schimpf2e7daef2015-01-09 13:04:13 -080044
Andrew Scull9612d322015-07-06 14:53:25 -070045 /// Reads MemBuf, assuming it is the PNaCl bitcode contents of IRFilename.
Karl Schimpf2e7daef2015-01-09 13:04:13 -080046 void translateBuffer(const std::string &IRFilename,
47 llvm::MemoryBuffer *MemBuf);
Karl Schimpf8d7abae2014-07-07 14:50:30 -070048};
Jim Stichnoth7b451a92014-10-15 14:39:23 -070049
50} // end of namespace Ice
Karl Schimpf8d7abae2014-07-07 14:50:30 -070051
52#endif // SUBZERO_SRC_PNACLTRANSLATOR_H