blob: 59403d284e12e9a9e3da62a0ab63236d1df15ed2 [file] [log] [blame]
Karl Schimpf8d7abae2014-07-07 14:50:30 -07001//===- subzero/src/IceTranslator.cpp - ICE to machine code ------*- 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 defines the general driver class for translating ICE to
11// machine code.
12//
13//===----------------------------------------------------------------------===//
14
15#include "IceTranslator.h"
16
17#include "IceCfg.h"
18#include "IceClFlags.h"
19#include "IceTargetLowering.h"
20
21#include <iostream>
22
23using namespace Ice;
24
25Translator::~Translator() {}
26
27void Translator::translateFcn(Ice::Cfg *Fcn) {
28 Func.reset(Fcn);
Jim Stichnoth989a7032014-08-08 10:13:44 -070029 if (Ctx->getFlags().DisableInternal)
Karl Schimpf8d7abae2014-07-07 14:50:30 -070030 Func->setInternal(false);
Jim Stichnoth989a7032014-08-08 10:13:44 -070031 if (Ctx->getFlags().DisableTranslation) {
Karl Schimpf8d7abae2014-07-07 14:50:30 -070032 Func->dump();
33 } else {
34 Ice::Timer TTranslate;
35 Func->translate();
Jim Stichnoth989a7032014-08-08 10:13:44 -070036 if (Ctx->getFlags().SubzeroTimingEnabled) {
Karl Schimpf8d7abae2014-07-07 14:50:30 -070037 std::cerr << "[Subzero timing] Translate function "
38 << Func->getFunctionName() << ": " << TTranslate.getElapsedSec()
39 << " sec\n";
40 }
41 if (Func->hasError()) {
42 std::cerr << "ICE translation error: " << Func->getError() << "\n";
Karl Schimpfb164d202014-07-11 10:26:34 -070043 ErrorStatus = true;
Karl Schimpf8d7abae2014-07-07 14:50:30 -070044 }
45
46 Ice::Timer TEmit;
47 Func->emit();
Jim Stichnoth989a7032014-08-08 10:13:44 -070048 if (Ctx->getFlags().SubzeroTimingEnabled) {
Karl Schimpf8d7abae2014-07-07 14:50:30 -070049 std::cerr << "[Subzero timing] Emit function " << Func->getFunctionName()
50 << ": " << TEmit.getElapsedSec() << " sec\n";
51 }
52 }
53}
54
55void Translator::emitConstants() {
Jim Stichnoth989a7032014-08-08 10:13:44 -070056 if (!Ctx->getFlags().DisableTranslation && Func)
Karl Schimpf8d7abae2014-07-07 14:50:30 -070057 Func->getTarget()->emitConstants();
58}