LLVM  3.7.0
WebAssemblyISelDAGToDAG.cpp
Go to the documentation of this file.
1 //- WebAssemblyISelDAGToDAG.cpp - A dag to dag inst selector for WebAssembly -//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file defines an instruction selector for the WebAssembly target.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #include "WebAssembly.h"
19 #include "llvm/IR/Function.h" // To access function attributes.
20 #include "llvm/Support/Debug.h"
23 using namespace llvm;
24 
25 #define DEBUG_TYPE "wasm-isel"
26 
27 //===--------------------------------------------------------------------===//
28 /// WebAssembly-specific code to select WebAssembly machine instructions for
29 /// SelectionDAG operations.
30 ///
31 namespace {
32 class WebAssemblyDAGToDAGISel final : public SelectionDAGISel {
33  /// Keep a pointer to the WebAssemblySubtarget around so that we can make the
34  /// right decision when generating code for different targets.
35  const WebAssemblySubtarget *Subtarget;
36 
37  bool ForCodeSize;
38 
39 public:
40  WebAssemblyDAGToDAGISel(WebAssemblyTargetMachine &tm,
41  CodeGenOpt::Level OptLevel)
42  : SelectionDAGISel(tm, OptLevel), Subtarget(nullptr), ForCodeSize(false) {
43  }
44 
45  const char *getPassName() const override {
46  return "WebAssembly Instruction Selection";
47  }
48 
49  bool runOnMachineFunction(MachineFunction &MF) override {
50  ForCodeSize =
53  Subtarget = &MF.getSubtarget<WebAssemblySubtarget>();
55  }
56 
57  SDNode *Select(SDNode *Node) override;
58 
59 private:
60  // add select functions here...
61 };
62 } // end anonymous namespace
63 
65  llvm_unreachable("TODO: implement Select");
66 }
67 
68 /// This pass converts a legalized DAG into a WebAssembly-specific DAG, ready
69 /// for instruction scheduling.
71  CodeGenOpt::Level OptLevel) {
72  return new WebAssemblyDAGToDAGISel(TM, OptLevel);
73 }
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
This file declares the WebAssembly-specific subclass of TargetMachine.
FunctionPass * createWebAssemblyISelDag(WebAssemblyTargetMachine &TM, CodeGenOpt::Level OptLevel)
This pass converts a legalized DAG into a WebAssembly-specific DAG, ready for instruction scheduling...
This file provides WebAssembly-specific target descriptions.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:294
Represents one node in the SelectionDAG.
SelectionDAGISel - This is the common base class used for SelectionDAG-based pattern-matching instruc...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:217
Function must be optimized for size first.
Definition: Attributes.h:80