]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Mips / MipsLegalizerInfo.cpp
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 #include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
17
18 using namespace llvm;
19
20 MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) {
21   using namespace TargetOpcode;
22
23   const LLT s1 = LLT::scalar(1);
24   const LLT s32 = LLT::scalar(32);
25   const LLT s64 = LLT::scalar(64);
26   const LLT p0 = LLT::pointer(0, 32);
27
28   getActionDefinitionsBuilder(G_ADD)
29       .legalFor({s32})
30       .clampScalar(0, s32, s32);
31
32   getActionDefinitionsBuilder(G_UADDE)
33       .lowerFor({{s32, s1}});
34
35   getActionDefinitionsBuilder({G_LOAD, G_STORE})
36       .legalForCartesianProduct({p0, s32}, {p0});
37
38   getActionDefinitionsBuilder(G_SELECT)
39       .legalForCartesianProduct({p0, s32}, {s32})
40       .minScalar(0, s32)
41       .minScalar(1, s32);
42
43   getActionDefinitionsBuilder({G_AND, G_OR, G_XOR})
44       .legalFor({s32})
45       .clampScalar(0, s32, s32);
46
47   getActionDefinitionsBuilder({G_SHL, G_ASHR, G_LSHR})
48       .legalFor({s32});
49
50   getActionDefinitionsBuilder({G_SDIV, G_SREM, G_UREM, G_UDIV})
51       .legalFor({s32})
52       .minScalar(0, s32)
53       .libcallFor({s64});
54
55   getActionDefinitionsBuilder(G_ICMP)
56       .legalFor({{s32, s32}})
57       .minScalar(0, s32);
58
59   getActionDefinitionsBuilder(G_CONSTANT)
60       .legalFor({s32})
61       .clampScalar(0, s32, s32);
62
63   getActionDefinitionsBuilder(G_GEP)
64       .legalFor({{p0, s32}});
65
66   getActionDefinitionsBuilder(G_FRAME_INDEX)
67       .legalFor({p0});
68
69   getActionDefinitionsBuilder(G_GLOBAL_VALUE)
70       .legalFor({p0});
71
72   computeTables();
73   verify(*ST.getInstrInfo());
74 }
75
76 bool MipsLegalizerInfo::legalizeCustom(MachineInstr &MI,
77                                        MachineRegisterInfo &MRI,
78                                        MachineIRBuilder &MIRBuilder,
79                                        GISelChangeObserver &Observer) const {
80
81   using namespace TargetOpcode;
82
83   MIRBuilder.setInstr(MI);
84
85   return false;
86 }