Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- MipsLegalizerInfo.cpp ------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
/// \file
9
/// This file implements the targeting of the Machinelegalizer class for Mips.
10
/// \todo This should be generated by TableGen.
11
//===----------------------------------------------------------------------===//
12
13
#include "MipsLegalizerInfo.h"
14
#include "MipsTargetMachine.h"
15
#include "llvm/CodeGen/GlobalISel/LegalizerHelper.h"
16
17
using namespace llvm;
18
19
11.3k
MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) {
20
11.3k
  using namespace TargetOpcode;
21
11.3k
22
11.3k
  const LLT s1 = LLT::scalar(1);
23
11.3k
  const LLT s32 = LLT::scalar(32);
24
11.3k
  const LLT s64 = LLT::scalar(64);
25
11.3k
  const LLT p0 = LLT::pointer(0, 32);
26
11.3k
27
11.3k
  getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL})
28
11.3k
      .legalFor({s32})
29
11.3k
      .clampScalar(0, s32, s32);
30
11.3k
31
11.3k
  getActionDefinitionsBuilder({G_UADDO, G_UADDE, G_USUBO, G_USUBE, G_UMULO})
32
11.3k
      .lowerFor({{s32, s1}});
33
11.3k
34
11.3k
  getActionDefinitionsBuilder(G_UMULH)
35
11.3k
      .legalFor({s32})
36
11.3k
      .maxScalar(0, s32);
37
11.3k
38
11.3k
  getActionDefinitionsBuilder({G_LOAD, G_STORE})
39
11.3k
      .legalForTypesWithMemDesc({{s32, p0, 8, 8},
40
11.3k
                                 {s32, p0, 16, 8},
41
11.3k
                                 {s32, p0, 32, 8},
42
11.3k
                                 {s64, p0, 64, 8},
43
11.3k
                                 {p0, p0, 32, 8}})
44
11.3k
      .minScalar(0, s32);
45
11.3k
46
11.3k
  getActionDefinitionsBuilder(G_UNMERGE_VALUES)
47
11.3k
     .legalFor({{s32, s64}});
48
11.3k
49
11.3k
  getActionDefinitionsBuilder(G_MERGE_VALUES)
50
11.3k
     .legalFor({{s64, s32}});
51
11.3k
52
11.3k
  getActionDefinitionsBuilder({G_ZEXTLOAD, G_SEXTLOAD})
53
11.3k
    .legalForTypesWithMemDesc({{s32, p0, 8, 8},
54
11.3k
                               {s32, p0, 16, 8}})
55
11.3k
      .minScalar(0, s32);
56
11.3k
57
11.3k
  getActionDefinitionsBuilder(G_SELECT)
58
11.3k
      .legalForCartesianProduct({p0, s32, s64}, {s32})
59
11.3k
      .minScalar(0, s32)
60
11.3k
      .minScalar(1, s32);
61
11.3k
62
11.3k
  getActionDefinitionsBuilder(G_BRCOND)
63
11.3k
      .legalFor({s32})
64
11.3k
      .minScalar(0, s32);
65
11.3k
66
11.3k
  getActionDefinitionsBuilder(G_PHI)
67
11.3k
      .legalFor({p0, s32, s64})
68
11.3k
      .minScalar(0, s32);
69
11.3k
70
11.3k
  getActionDefinitionsBuilder({G_AND, G_OR, G_XOR})
71
11.3k
      .legalFor({s32})
72
11.3k
      .clampScalar(0, s32, s32);
73
11.3k
74
11.3k
  getActionDefinitionsBuilder({G_SDIV, G_SREM, G_UREM, G_UDIV})
75
11.3k
      .legalFor({s32})
76
11.3k
      .minScalar(0, s32)
77
11.3k
      .libcallFor({s64});
78
11.3k
79
11.3k
  getActionDefinitionsBuilder({G_SHL, G_ASHR, G_LSHR})
80
11.3k
    .legalFor({s32, s32})
81
11.3k
    .minScalar(1, s32);
82
11.3k
83
11.3k
  getActionDefinitionsBuilder(G_ICMP)
84
11.3k
      .legalForCartesianProduct({s32}, {s32, p0})
85
11.3k
      .clampScalar(1, s32, s32)
86
11.3k
      .minScalar(0, s32);
87
11.3k
88
11.3k
  getActionDefinitionsBuilder(G_CONSTANT)
89
11.3k
      .legalFor({s32})
90
11.3k
      .clampScalar(0, s32, s32);
91
11.3k
92
11.3k
  getActionDefinitionsBuilder(G_GEP)
93
11.3k
      .legalFor({{p0, s32}});
94
11.3k
95
11.3k
  getActionDefinitionsBuilder(G_FRAME_INDEX)
96
11.3k
      .legalFor({p0});
97
11.3k
98
11.3k
  getActionDefinitionsBuilder(G_GLOBAL_VALUE)
99
11.3k
      .legalFor({p0});
100
11.3k
101
11.3k
  // FP instructions
102
11.3k
  getActionDefinitionsBuilder(G_FCONSTANT)
103
11.3k
      .legalFor({s32, s64});
104
11.3k
105
11.3k
  getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FABS, G_FSQRT})
106
11.3k
      .legalFor({s32, s64});
107
11.3k
108
11.3k
  getActionDefinitionsBuilder(G_FCMP)
109
11.3k
      .legalFor({{s32, s32}, {s32, s64}})
110
11.3k
      .minScalar(0, s32);
111
11.3k
112
11.3k
  getActionDefinitionsBuilder({G_FCEIL, G_FFLOOR})
113
11.3k
      .libcallFor({s32, s64});
114
11.3k
115
11.3k
  getActionDefinitionsBuilder(G_FPEXT)
116
11.3k
      .legalFor({{s64, s32}});
117
11.3k
118
11.3k
  getActionDefinitionsBuilder(G_FPTRUNC)
119
11.3k
      .legalFor({{s32, s64}});
120
11.3k
121
11.3k
  // FP to int conversion instructions
122
11.3k
  getActionDefinitionsBuilder(G_FPTOSI)
123
11.3k
      .legalForCartesianProduct({s32}, {s64, s32})
124
11.3k
      .libcallForCartesianProduct({s64}, {s64, s32})
125
11.3k
      .minScalar(0, s32);
126
11.3k
127
11.3k
  getActionDefinitionsBuilder(G_FPTOUI)
128
11.3k
      .libcallForCartesianProduct({s64}, {s64, s32})
129
11.3k
      .minScalar(0, s32);
130
11.3k
131
11.3k
  // Int to FP conversion instructions
132
11.3k
  getActionDefinitionsBuilder(G_SITOFP)
133
11.3k
      .legalForCartesianProduct({s64, s32}, {s32})
134
11.3k
      .libcallForCartesianProduct({s64, s32}, {s64})
135
11.3k
      .minScalar(1, s32);
136
11.3k
137
11.3k
  getActionDefinitionsBuilder(G_UITOFP)
138
11.3k
      .libcallForCartesianProduct({s64, s32}, {s64})
139
11.3k
      .minScalar(1, s32);
140
11.3k
141
11.3k
  computeTables();
142
11.3k
  verify(*ST.getInstrInfo());
143
11.3k
}
144
145
bool MipsLegalizerInfo::legalizeCustom(MachineInstr &MI,
146
                                       MachineRegisterInfo &MRI,
147
                                       MachineIRBuilder &MIRBuilder,
148
0
                                       GISelChangeObserver &Observer) const {
149
0
150
0
  using namespace TargetOpcode;
151
0
152
0
  MIRBuilder.setInstr(MI);
153
0
154
0
  return false;
155
0
}
156
157
bool MipsLegalizerInfo::legalizeIntrinsic(MachineInstr &MI, MachineRegisterInfo &MRI,
158
2
                                          MachineIRBuilder &MIRBuilder) const {
159
2
  switch (MI.getIntrinsicID()) {
160
2
  case Intrinsic::memcpy:
161
2
  case Intrinsic::memset:
162
2
  case Intrinsic::memmove:
163
2
    if (createMemLibcall(MIRBuilder, MRI, MI) ==
164
2
        LegalizerHelper::UnableToLegalize)
165
0
      return false;
166
2
    MI.eraseFromParent();
167
2
    return true;
168
2
  default:
169
0
    break;
170
0
  }
171
0
  return true;
172
0
}