OpenASIP  2.0
Macros | Functions
LowerMissingInstructions.cc File Reference
#include "CompilerWarnings.hh"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
#include "tce_config.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Constants.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
#include "llvm/IR/AbstractCallSite.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
#include "Machine.hh"
#include "OperationDAGSelector.hh"
#include "MachineInfo.hh"
#include "Operand.hh"
#include "Operation.hh"
#include "OperationPool.hh"
#include "TCEString.hh"
#include "LLVMBackend.hh"
#include <iostream>
Include dependency graph for LowerMissingInstructions.cc:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "lowermissing"
 
#define ARGLIST_CONST
 
#define TYPE_CONST
 

Functions

 STATISTIC (NumLowered, "Number of instructions lowered")
 
Pass * createLowerMissingInstructionsPass (const TTAMachine::Machine &mach)
 
const std::vector< std::string > & llvmFootprints (std::string tceOp)
 

Detailed Description

Convert instruction which are not supported by the machine to function calls.

NOTE: Right now system is limited to replace only those operations, which use only one bitwidth integers for example i1.icmp.i32.i32 cannot be lowered to function call. However i16.mul.i16.i16 works.

Maybe better way would be to take llvm footprints which must be emulated and create function prototype directly for them.

Author
Mikael Lepisto 2008-2009 (mikael.lepisto-no.spam-tut.fi)
Pekka Jaaskelainen 2010
Note
reting: red

Definition in file LowerMissingInstructions.cc.

Macro Definition Documentation

◆ ARGLIST_CONST

#define ARGLIST_CONST

Definition at line 91 of file LowerMissingInstructions.cc.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lowermissing"

Definition at line 45 of file LowerMissingInstructions.cc.

◆ TYPE_CONST

#define TYPE_CONST

Definition at line 92 of file LowerMissingInstructions.cc.

Function Documentation

◆ createLowerMissingInstructionsPass()

Pass* createLowerMissingInstructionsPass ( const TTAMachine::Machine mach)

Definition at line 147 of file LowerMissingInstructions.cc.

147  {
148  return new LowerMissingInstructions(mach);
149 }

Referenced by llvm::TCEPassConfig::addPreISel().

◆ llvmFootprints()

const std::vector<std::string>& llvmFootprints ( std::string  tceOp)

Definition at line 209 of file LowerMissingInstructions.cc.

209  {
210  static bool init = true;
211  static std::map<std::string, std::vector<std::string> > footprints;
212 
213  // NOTE: .i32 is default footprint suffix if there is no i16, i8 or i1
214  // versions.. e.g. .i32 is suffix for f32.fadd.f32.f32
215  if (init) {
216 // footprints["DIVU.i32"].push_back("i32.udiv.i32.i32");
217 // footprints["DIVU.i16"].push_back("i16.udiv.i16.i16");
218 // footprints["DIVU.i8"].push_back("i8.udiv.i8.i8");
219 
220 // footprints["DIV.i32"].push_back("i32.sdiv.i32.i32");
221 // footprints["DIV.i16"].push_back("i16.sdiv.i16.i16");
222 // footprints["DIV.i8"].push_back("i8.sdiv.i8.i8");
223 
224 // footprints["MODU.i32"].push_back("i32.urem.i32.i32");
225 // footprints["MODU.i16"].push_back("i16.urem.i16.i16");
226 // footprints["MODU.i8"].push_back("i8.urem.i8.i8");
227 
228 // footprints["MOD.i32"].push_back("i32.rem.i32.i32");
229 // footprints["MOD.i16"].push_back("i16.rem.i16.i16");
230 // footprints["MOD.i8"].push_back("i8.rem.i8.i8");
231 
232 // footprints["MUL.i32"].push_back("i32.mul.i32.i32");
233 // footprints["MUL.i16"].push_back("i16.mul.i16.i16");
234 // footprints["MUL.i8"].push_back("i8.mul.i8.i8");
235  footprints["ADDH.i32"].push_back("f16.fadd.f16.f16");
236  footprints["SUBH.i32"].push_back("f16.fsub.f16.f16");
237  footprints["NEGH.i32"].push_back("f16.fneg.f16");
238  footprints["MULH.i32"].push_back("f16.fmul.f16.f16");
239  footprints["DIVH.i32"].push_back("f16.fdiv.f16.f16");
240  footprints["SQRTH.i32"].push_back("f16.sqrt.f16");
241 
242  footprints["ADDF.i32"].push_back("f32.fadd.f32.f32");
243  footprints["SUBF.i32"].push_back("f32.fsub.f32.f32");
244  footprints["NEGF.i32"].push_back("f32.fneg.f32");
245  footprints["MULF.i32"].push_back("f32.fmul.f32.f32");
246  footprints["DIVF.i32"].push_back("f32.fdiv.f32.f32");
247  footprints["SQRTF.i32"].push_back("f32.sqrt.f32");
248 
249  footprints["ADDD.i64"].push_back("f64.fadd.f64.f64");
250  footprints["SUBD.i64"].push_back("f64.fsub.f64.f64");
251  footprints["NEGD.i64"].push_back("f64.fneg.f64");
252  footprints["MULD.i64"].push_back("f64.fmul.f64.f64");
253  footprints["DIVD.i64"].push_back("f64.fdiv.f64.f64");
254  footprints["SQRTD.i64"].push_back("f64.sqrt.f64");
255 
256  footprints["CFI.i32"].push_back("i32.fptosi.f32");
257  footprints["CFIU.i32"].push_back("i32.fptoui.f32");
258  footprints["CIF.i32"].push_back("f32.sitofp.i32");
259  footprints["CIFU.i32"].push_back("f32.uitofp.i32");
260 
261  footprints["CFI.i16"].push_back("i16.fptosi.f32");
262  footprints["CFIU.i16"].push_back("i16.fptoui.f32");
263  footprints["CIF.i16"].push_back("f32.sitofp.i16");
264  footprints["CIFU.i16"].push_back("f32.uitofp.i16");
265 
266  footprints["CFI.i8"].push_back("i8.fptosi.f32");
267  footprints["CFIU.i8"].push_back("i8.fptoui.f32");
268  footprints["CIF.i8"].push_back("f32.sitofp.i8");
269  footprints["CIFU.i8"].push_back("f32.uitofp.i8");
270 
271  footprints["CDL.i64"].push_back("i64.fptosi.f64");
272  footprints["CDLU.i64"].push_back("i64.fptoui.f64");
273  footprints["CLD.i64"].push_back("f64.sitofp.i64");
274  footprints["CLDU.i64"].push_back("f64.uitofp.i64");
275 
276  footprints["CDL.i32"].push_back("i32.fptosi.f64");
277  footprints["CDLU.i32"].push_back("i32.fptoui.f64");
278  footprints["CLD.i32"].push_back("f64.sitofp.i32");
279  footprints["CLDU.i32"].push_back("f64.uitofp.i32");
280 
281  footprints["CDL.i16"].push_back("i16.fptosi.f64");
282  footprints["CDLU.i16"].push_back("i16.fptoui.f64");
283  footprints["CLD.i16"].push_back("f64.sitofp.i16");
284  footprints["CLDU.i16"].push_back("f64.uitofp.i16");
285 
286  footprints["CDL.i8"].push_back("i8.fptosi.f64");
287  footprints["CDLU.i8"].push_back("i8.fptoui.f64");
288  footprints["CLD.i8"].push_back("f64.sitofp.i8");
289  footprints["CLDU.i8"].push_back("f64.uitofp.i8");
290 
291  footprints["EQF.i1"].push_back("i1.fcmp.oeq.f32.f32");
292  footprints["NEF.i1"].push_back("i1.fcmp.one.f32.f32");
293  footprints["LTF.i1"].push_back("i1.fcmp.olt.f32.f32");
294  footprints["LEF.i1"].push_back("i1.fcmp.ole.f32.f32");
295  footprints["GTF.i1"].push_back("i1.fcmp.ogt.f32.f32");
296  footprints["GEF.i1"].push_back("i1.fcmp.oge.f32.f32");
297 
298  footprints["EQUF.i1"].push_back("i1.fcmp.ueq.f32.f32");
299  footprints["NEUF.i1"].push_back("i1.fcmp.une.f32.f32");
300  footprints["LTUF.i1"].push_back("i1.fcmp.ult.f32.f32");
301  footprints["LEUF.i1"].push_back("i1.fcmp.ule.f32.f32");
302  footprints["GTUF.i1"].push_back("i1.fcmp.ugt.f32.f32");
303  footprints["GEUF.i1"].push_back("i1.fcmp.uge.f32.f32");
304 
305  footprints["EQF.i32"].push_back("i32.fcmp.oeq.f32.f32");
306  footprints["NEF.i32"].push_back("i32.fcmp.one.f32.f32");
307  footprints["LTF.i32"].push_back("i32.fcmp.olt.f32.f32");
308  footprints["LEF.i32"].push_back("i32.fcmp.ole.f32.f32");
309  footprints["GTF.i32"].push_back("i32.fcmp.ogt.f32.f32");
310  footprints["GEF.i32"].push_back("i32.fcmp.oge.f32.f32");
311 
312  footprints["EQUF.i32"].push_back("i32.fcmp.ueq.f32.f32");
313  footprints["NEUF.i32"].push_back("i32.fcmp.une.f32.f32");
314  footprints["LTUF.i32"].push_back("i32.fcmp.ult.f32.f32");
315  footprints["LEUF.i32"].push_back("i32.fcmp.ule.f32.f32");
316  footprints["GTUF.i32"].push_back("i32.fcmp.ugt.f32.f32");
317  footprints["GEUF.i32"].push_back("i32.fcmp.uge.f32.f32");
318 
319  footprints["ORDF.i1"].push_back("i1.fcmp.ord.f32.f32");
320  footprints["ORDF.i32"].push_back("i32.fcmp.ord.f32.f32");
321  footprints["UORDF.i1"].push_back("i1.fcmp.uno.f32.f32");
322  footprints["UORDF.i32"].push_back("i32.fcmp.uno.f32.f32");
323 
324  footprints["CFD.i64"].push_back("f64.fpext.f32");
325 
326  footprints["EQD.i1"].push_back("i1.fcmp.oeq.f64.f64");
327  footprints["NED.i1"].push_back("i1.fcmp.one.f64.f64");
328  footprints["LTD.i1"].push_back("i1.fcmp.olt.f64.f64");
329  footprints["GED.i1"].push_back("i1.fcmp.oge.f64.f64");
330  footprints["LED.i1"].push_back("i1.fcmp.ole.f64.f64");
331  footprints["GTD.i1"].push_back("i1.fcmp.ogt.f64.f64");
332 
333  footprints["EQD.i64"].push_back("i64.fcmp.oeq.f64.f64");
334  footprints["NED.i64"].push_back("i64.fcmp.one.f64.f64");
335  footprints["LTD.i64"].push_back("i64.fcmp.olt.f64.f64");
336  footprints["GED.i64"].push_back("i64.fcmp.oge.f64.f64");
337  footprints["LED.i64"].push_back("i64.fcmp.ole.f64.f64");
338  footprints["GTD.i64"].push_back("i64.fcmp.ogt.f64.f64");
339 
340  footprints["EQUD.i1"].push_back("i1.fcmp.ueq.f64.f64");
341  footprints["NEUD.i1"].push_back("i1.fcmp.une.f64.f64");
342  footprints["GEUD.i1"].push_back("i1.fcmp.uge.f64.f64");
343  footprints["LEUD.i1"].push_back("i1.fcmp.ule.f64.f64");
344  footprints["LTUD.i1"].push_back("i1.fcmp.ult.f64.f64");
345  footprints["GTUD.i1"].push_back("i1.fcmp.ugt.f64.f64");
346 
347  footprints["EQUD.i64"].push_back("i64.fcmp.ueq.f64.f64");
348  footprints["NEUD.i64"].push_back("i64.fcmp.une.f64.f64");
349  footprints["LEUD.i64"].push_back("i64.fcmp.ule.f64.f64");
350  footprints["GEUD.i64"].push_back("i64.fcmp.uge.f64.f64");
351  footprints["LTUD.i64"].push_back("i64.fcmp.ult.f64.f64");
352  footprints["GTUD.i64"].push_back("i64.fcmp.ugt.f64.f64");
353 
354  footprints["ORDD.i1"].push_back("i1.fcmp.ord.f64.f64");
355  footprints["ORDD.i64"].push_back("i64.fcmp.ord.f64.f64");
356  footprints["UORDD.i1"].push_back("i1.fcmp.uno.f64.f64");
357  footprints["UORDD.i64"].push_back("i64.fcmp.uno.f64.f64");
358 
359  init = false;
360  }
361 
362  return footprints[tceOp];
363 }

◆ STATISTIC()

STATISTIC ( NumLowered  ,
"Number of instructions lowered"   
)