1 //===- MipsLegalizerInfo.cpp ------------------------------------*- C++ -*-===//
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 /// \file
10 /// This file implements the targeting of the Machinelegalizer class for Mips.
11 /// \todo This should be generated by TableGen.
12 //===----------------------------------------------------------------------===//
13 
14 #include "MipsLegalizerInfo.h"
15 #include "MipsTargetMachine.h"
16 
17 using namespace llvm;
18 
19 MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) {
20   using namespace TargetOpcode;
21 
22   const LLT s32 = LLT::scalar(32);
23   const LLT p0 = LLT::pointer(0, 32);
24 
25   getActionDefinitionsBuilder(G_ADD)
26       .legalFor({s32})
27       .minScalar(0, s32);
28 
29   getActionDefinitionsBuilder({G_LOAD, G_STORE})
30       .legalForCartesianProduct({p0, s32}, {p0});
31 
32   getActionDefinitionsBuilder({G_AND, G_OR, G_XOR, G_SHL, G_ASHR, G_LSHR})
33       .legalFor({s32});
34 
35   getActionDefinitionsBuilder(G_CONSTANT)
36       .legalFor({s32});
37 
38   getActionDefinitionsBuilder(G_GEP)
39       .legalFor({{p0, s32}});
40 
41   getActionDefinitionsBuilder(G_FRAME_INDEX)
42       .legalFor({p0});
43 
44   getActionDefinitionsBuilder(G_GLOBAL_VALUE)
45       .legalFor({p0});
46 
47   computeTables();
48   verify(*ST.getInstrInfo());
49 }
50