blob: b8764a6d1656822079ae15ce98f29546ac8a2606 [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//===----------------------------------------------------------------------===//
9//
10// This file declares the PNaCl bitcode file to ICE, to machine code
11// translator.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef SUBZERO_SRC_PNACLTRANSLATOR_H
16#define SUBZERO_SRC_PNACLTRANSLATOR_H
17
Jim Stichnotha18cc9c2014-09-30 19:10:22 -070018#include "IceTranslator.h"
19
John Porto67f8de92015-06-25 10:14:17 -070020#include <string>
21
Karl Schimpf2e7daef2015-01-09 13:04:13 -080022namespace llvm {
23class MemoryBuffer;
Jan Voungc1f07ea2015-03-06 14:53:30 -080024class MemoryObject;
Karl Schimpf2e7daef2015-01-09 13:04:13 -080025} // end of namespace llvm
26
Karl Schimpf8d7abae2014-07-07 14:50:30 -070027namespace Ice {
28
29class PNaClTranslator : public Translator {
Jim Stichnothc6ead202015-02-24 09:30:30 -080030 PNaClTranslator() = delete;
Jim Stichnoth7b451a92014-10-15 14:39:23 -070031 PNaClTranslator(const PNaClTranslator &) = delete;
32 PNaClTranslator &operator=(const PNaClTranslator &) = delete;
33
Karl Schimpf8d7abae2014-07-07 14:50:30 -070034public:
Jim Stichnothc6ead202015-02-24 09:30:30 -080035 explicit PNaClTranslator(GlobalContext *Ctx) : Translator(Ctx) {}
Karl Schimpf2e7daef2015-01-09 13:04:13 -080036
Karl Schimpf8d7abae2014-07-07 14:50:30 -070037 // Reads the PNaCl bitcode file and translates to ICE, which is then
Jim Stichnothfa4efea2015-01-27 05:06:03 -080038 // converted to machine code. Sets ErrorStatus to 1 if any errors
Jan Voungc1f07ea2015-03-06 14:53:30 -080039 // occurred. Takes ownership of the MemoryObject.
40 void translate(const std::string &IRFilename,
41 std::unique_ptr<llvm::MemoryObject> &&MemoryObject);
Karl Schimpf2e7daef2015-01-09 13:04:13 -080042
43 // Reads MemBuf, assuming it is the PNaCl bitcode contents of IRFilename.
44 void translateBuffer(const std::string &IRFilename,
45 llvm::MemoryBuffer *MemBuf);
Karl Schimpf8d7abae2014-07-07 14:50:30 -070046};
Jim Stichnoth7b451a92014-10-15 14:39:23 -070047
48} // end of namespace Ice
Karl Schimpf8d7abae2014-07-07 14:50:30 -070049
50#endif // SUBZERO_SRC_PNACLTRANSLATOR_H