diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:46:15 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-12-30 11:46:15 +0000 | 
| commit | dd58ef019b700900793a1eb48b52123db01b654e (patch) | |
| tree | fcfbb4df56a744f4ddc6122c50521dd3f1c5e196 /lib/Target/WebAssembly/WebAssemblyFastISel.cpp | |
| parent | 2fe5752e3a7c345cdb59e869278d36af33c13fa4 (diff) | |
Notes
Diffstat (limited to 'lib/Target/WebAssembly/WebAssemblyFastISel.cpp')
| -rw-r--r-- | lib/Target/WebAssembly/WebAssemblyFastISel.cpp | 81 | 
1 files changed, 81 insertions, 0 deletions
diff --git a/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/lib/Target/WebAssembly/WebAssemblyFastISel.cpp new file mode 100644 index 000000000000..1b761b1a9d73 --- /dev/null +++ b/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -0,0 +1,81 @@ +//===-- WebAssemblyFastISel.cpp - WebAssembly FastISel implementation -----===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief This file defines the WebAssembly-specific support for the FastISel +/// class. Some of the target-specific code is generated by tablegen in the file +/// WebAssemblyGenFastISel.inc, which is #included here. +/// +//===----------------------------------------------------------------------===// + +#include "WebAssembly.h" +#include "MCTargetDesc/WebAssemblyMCTargetDesc.h" +#include "WebAssemblySubtarget.h" +#include "WebAssemblyTargetMachine.h" +#include "llvm/Analysis/BranchProbabilityInfo.h" +#include "llvm/CodeGen/FastISel.h" +#include "llvm/CodeGen/FunctionLoweringInfo.h" +#include "llvm/CodeGen/MachineConstantPool.h" +#include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Function.h" +#include "llvm/IR/GetElementPtrTypeIterator.h" +#include "llvm/IR/GlobalAlias.h" +#include "llvm/IR/GlobalVariable.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/Operator.h" +using namespace llvm; + +#define DEBUG_TYPE "wasm-fastisel" + +namespace { + +class WebAssemblyFastISel final : public FastISel { +  /// Keep a pointer to the WebAssemblySubtarget around so that we can make the +  /// right decision when generating code for different targets. +  const WebAssemblySubtarget *Subtarget; +  LLVMContext *Context; + +  // Call handling routines. +private: +public: +  // Backend specific FastISel code. +  WebAssemblyFastISel(FunctionLoweringInfo &FuncInfo, +                      const TargetLibraryInfo *LibInfo) +      : FastISel(FuncInfo, LibInfo, /*SkipTargetIndependentISel=*/true) { +    Subtarget = &FuncInfo.MF->getSubtarget<WebAssemblySubtarget>(); +    Context = &FuncInfo.Fn->getContext(); +  } + +  bool fastSelectInstruction(const Instruction *I) override; + +#include "WebAssemblyGenFastISel.inc" +}; + +} // end anonymous namespace + +bool WebAssemblyFastISel::fastSelectInstruction(const Instruction *I) { +  switch (I->getOpcode()) { +  default: +    break; +    // TODO: add fast-isel selection cases here... +  } + +  // Fall back to target-independent instruction selection. +  return selectOperator(I, I->getOpcode()); +} + +FastISel *WebAssembly::createFastISel(FunctionLoweringInfo &FuncInfo, +                                      const TargetLibraryInfo *LibInfo) { +  return new WebAssemblyFastISel(FuncInfo, LibInfo); +}  | 
