Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/Lanai/LanaiAluCode.h
Line
Count
Source (jump to first uncovered line)
1
//===-- LanaiAluCode.h - ALU operator encoding ----------------------------===//
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
//
9
// The encoding for ALU operators used in RM and RRM operands
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_LIB_TARGET_LANAI_LANAIALUCODE_H
14
#define LLVM_LIB_TARGET_LANAI_LANAIALUCODE_H
15
16
#include "llvm/ADT/StringSwitch.h"
17
#include "llvm/CodeGen/ISDOpcodes.h"
18
#include "llvm/Support/ErrorHandling.h"
19
20
namespace llvm {
21
namespace LPAC {
22
enum AluCode {
23
  ADD = 0x00,
24
  ADDC = 0x01,
25
  SUB = 0x02,
26
  SUBB = 0x03,
27
  AND = 0x04,
28
  OR = 0x05,
29
  XOR = 0x06,
30
  SPECIAL = 0x07,
31
32
  // Shift instructions are treated as SPECIAL when encoding the machine
33
  // instruction, but kept distinct until lowering. The constant values are
34
  // chosen to ease lowering.
35
  SHL = 0x17,
36
  SRL = 0x27,
37
  SRA = 0x37,
38
39
  // Indicates an unknown/unsupported operator
40
  UNKNOWN = 0xFF,
41
};
42
43
// Bits indicating post- and pre-operators should be tested and set using Is*
44
// and Make* utility functions
45
const int Lanai_PRE_OP = 0x40;
46
const int Lanai_POST_OP = 0x80;
47
48
575
inline static unsigned encodeLanaiAluCode(unsigned AluOp) {
49
575
  unsigned const OP_ENCODING_MASK = 0x07;
50
575
  return AluOp & OP_ENCODING_MASK;
51
575
}
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Unexecuted instantiation: LanaiMemAluCombiner.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Unexecuted instantiation: LanaiAsmParser.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
LanaiInstPrinter.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Line
Count
Source
48
321
inline static unsigned encodeLanaiAluCode(unsigned AluOp) {
49
321
  unsigned const OP_ENCODING_MASK = 0x07;
50
321
  return AluOp & OP_ENCODING_MASK;
51
321
}
LanaiMCCodeEmitter.cpp:llvm::LPAC::encodeLanaiAluCode(unsigned int)
Line
Count
Source
48
254
inline static unsigned encodeLanaiAluCode(unsigned AluOp) {
49
254
  unsigned const OP_ENCODING_MASK = 0x07;
50
254
  return AluOp & OP_ENCODING_MASK;
51
254
}
52
53
499
inline static unsigned getAluOp(unsigned AluOp) {
54
499
  unsigned const ALU_MASK = 0x3F;
55
499
  return AluOp & ALU_MASK;
56
499
}
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::getAluOp(unsigned int)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::getAluOp(unsigned int)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::getAluOp(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::getAluOp(unsigned int)
Unexecuted instantiation: LanaiMemAluCombiner.cpp:llvm::LPAC::getAluOp(unsigned int)
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::getAluOp(unsigned int)
Unexecuted instantiation: LanaiAsmParser.cpp:llvm::LPAC::getAluOp(unsigned int)
LanaiInstPrinter.cpp:llvm::LPAC::getAluOp(unsigned int)
Line
Count
Source
53
245
inline static unsigned getAluOp(unsigned AluOp) {
54
245
  unsigned const ALU_MASK = 0x3F;
55
245
  return AluOp & ALU_MASK;
56
245
}
LanaiMCCodeEmitter.cpp:llvm::LPAC::getAluOp(unsigned int)
Line
Count
Source
53
254
inline static unsigned getAluOp(unsigned AluOp) {
54
254
  unsigned const ALU_MASK = 0x3F;
55
254
  return AluOp & ALU_MASK;
56
254
}
57
58
2.12k
inline static bool isPreOp(unsigned AluOp) { return AluOp & Lanai_PRE_OP; }
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::isPreOp(unsigned int)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::isPreOp(unsigned int)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::isPreOp(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::isPreOp(unsigned int)
LanaiMemAluCombiner.cpp:llvm::LPAC::isPreOp(unsigned int)
Line
Count
Source
58
68
inline static bool isPreOp(unsigned AluOp) { return AluOp & Lanai_PRE_OP; }
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::isPreOp(unsigned int)
Unexecuted instantiation: LanaiAsmParser.cpp:llvm::LPAC::isPreOp(unsigned int)
LanaiInstPrinter.cpp:llvm::LPAC::isPreOp(unsigned int)
Line
Count
Source
58
1.20k
inline static bool isPreOp(unsigned AluOp) { return AluOp & Lanai_PRE_OP; }
LanaiMCCodeEmitter.cpp:llvm::LPAC::isPreOp(unsigned int)
Line
Count
Source
58
856
inline static bool isPreOp(unsigned AluOp) { return AluOp & Lanai_PRE_OP; }
59
60
2.27k
inline static bool isPostOp(unsigned AluOp) { return AluOp & Lanai_POST_OP; }
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::isPostOp(unsigned int)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::isPostOp(unsigned int)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::isPostOp(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::isPostOp(unsigned int)
LanaiMemAluCombiner.cpp:llvm::LPAC::isPostOp(unsigned int)
Line
Count
Source
60
68
inline static bool isPostOp(unsigned AluOp) { return AluOp & Lanai_POST_OP; }
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::isPostOp(unsigned int)
Unexecuted instantiation: LanaiAsmParser.cpp:llvm::LPAC::isPostOp(unsigned int)
LanaiInstPrinter.cpp:llvm::LPAC::isPostOp(unsigned int)
Line
Count
Source
60
1.06k
inline static bool isPostOp(unsigned AluOp) { return AluOp & Lanai_POST_OP; }
LanaiMCCodeEmitter.cpp:llvm::LPAC::isPostOp(unsigned int)
Line
Count
Source
60
1.15k
inline static bool isPostOp(unsigned AluOp) { return AluOp & Lanai_POST_OP; }
61
62
204
inline static unsigned makePreOp(unsigned AluOp) {
63
204
  assert(!isPostOp(AluOp) && "Operator can't be a post- and pre-op");
64
204
  return AluOp | Lanai_PRE_OP;
65
204
}
LanaiAsmPrinter.cpp:llvm::LPAC::makePreOp(unsigned int)
Line
Count
Source
62
13
inline static unsigned makePreOp(unsigned AluOp) {
63
13
  assert(!isPostOp(AluOp) && "Operator can't be a post- and pre-op");
64
13
  return AluOp | Lanai_PRE_OP;
65
13
}
LanaiFrameLowering.cpp:llvm::LPAC::makePreOp(unsigned int)
Line
Count
Source
62
92
inline static unsigned makePreOp(unsigned AluOp) {
63
92
  assert(!isPostOp(AluOp) && "Operator can't be a post- and pre-op");
64
92
  return AluOp | Lanai_PRE_OP;
65
92
}
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::makePreOp(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::makePreOp(unsigned int)
Unexecuted instantiation: LanaiMemAluCombiner.cpp:llvm::LPAC::makePreOp(unsigned int)
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::makePreOp(unsigned int)
LanaiAsmParser.cpp:llvm::LPAC::makePreOp(unsigned int)
Line
Count
Source
62
99
inline static unsigned makePreOp(unsigned AluOp) {
63
99
  assert(!isPostOp(AluOp) && "Operator can't be a post- and pre-op");
64
99
  return AluOp | Lanai_PRE_OP;
65
99
}
Unexecuted instantiation: LanaiInstPrinter.cpp:llvm::LPAC::makePreOp(unsigned int)
Unexecuted instantiation: LanaiMCCodeEmitter.cpp:llvm::LPAC::makePreOp(unsigned int)
66
67
103
inline static unsigned makePostOp(unsigned AluOp) {
68
103
  assert(!isPreOp(AluOp) && "Operator can't be a post- and pre-op");
69
103
  return AluOp | Lanai_POST_OP;
70
103
}
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::makePostOp(unsigned int)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::makePostOp(unsigned int)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::makePostOp(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::makePostOp(unsigned int)
LanaiMemAluCombiner.cpp:llvm::LPAC::makePostOp(unsigned int)
Line
Count
Source
67
1
inline static unsigned makePostOp(unsigned AluOp) {
68
1
  assert(!isPreOp(AluOp) && "Operator can't be a post- and pre-op");
69
1
  return AluOp | Lanai_POST_OP;
70
1
}
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::makePostOp(unsigned int)
LanaiAsmParser.cpp:llvm::LPAC::makePostOp(unsigned int)
Line
Count
Source
67
102
inline static unsigned makePostOp(unsigned AluOp) {
68
102
  assert(!isPreOp(AluOp) && "Operator can't be a post- and pre-op");
69
102
  return AluOp | Lanai_POST_OP;
70
102
}
Unexecuted instantiation: LanaiInstPrinter.cpp:llvm::LPAC::makePostOp(unsigned int)
Unexecuted instantiation: LanaiMCCodeEmitter.cpp:llvm::LPAC::makePostOp(unsigned int)
71
72
362
inline static bool modifiesOp(unsigned AluOp) {
73
362
  return isPreOp(AluOp) | isPostOp(AluOp);
74
362
}
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::modifiesOp(unsigned int)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::modifiesOp(unsigned int)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::modifiesOp(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::modifiesOp(unsigned int)
LanaiMemAluCombiner.cpp:llvm::LPAC::modifiesOp(unsigned int)
Line
Count
Source
72
68
inline static bool modifiesOp(unsigned AluOp) {
73
68
  return isPreOp(AluOp) | isPostOp(AluOp);
74
68
}
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::modifiesOp(unsigned int)
Unexecuted instantiation: LanaiAsmParser.cpp:llvm::LPAC::modifiesOp(unsigned int)
Unexecuted instantiation: LanaiInstPrinter.cpp:llvm::LPAC::modifiesOp(unsigned int)
LanaiMCCodeEmitter.cpp:llvm::LPAC::modifiesOp(unsigned int)
Line
Count
Source
72
294
inline static bool modifiesOp(unsigned AluOp) {
73
294
  return isPreOp(AluOp) | isPostOp(AluOp);
74
294
}
75
76
245
inline static const char *lanaiAluCodeToString(unsigned AluOp) {
77
245
  switch (getAluOp(AluOp)) {
78
245
  case ADD:
79
56
    return "add";
80
245
  case ADDC:
81
24
    return "addc";
82
245
  case SUB:
83
27
    return "sub";
84
245
  case SUBB:
85
24
    return "subb";
86
245
  case AND:
87
24
    return "and";
88
245
  case OR:
89
24
    return "or";
90
245
  case XOR:
91
24
    return "xor";
92
245
  case SHL:
93
9
    return "sh";
94
245
  case SRL:
95
9
    return "sh";
96
245
  case SRA:
97
24
    return "sha";
98
245
  default:
99
0
    llvm_unreachable("Invalid ALU code.");
100
245
  }
101
245
}
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
Unexecuted instantiation: LanaiMemAluCombiner.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
Unexecuted instantiation: LanaiAsmParser.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
LanaiInstPrinter.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
Line
Count
Source
76
245
inline static const char *lanaiAluCodeToString(unsigned AluOp) {
77
245
  switch (getAluOp(AluOp)) {
78
245
  case ADD:
79
56
    return "add";
80
245
  case ADDC:
81
24
    return "addc";
82
245
  case SUB:
83
27
    return "sub";
84
245
  case SUBB:
85
24
    return "subb";
86
245
  case AND:
87
24
    return "and";
88
245
  case OR:
89
24
    return "or";
90
245
  case XOR:
91
24
    return "xor";
92
245
  case SHL:
93
9
    return "sh";
94
245
  case SRL:
95
9
    return "sh";
96
245
  case SRA:
97
24
    return "sha";
98
245
  default:
99
0
    llvm_unreachable("Invalid ALU code.");
100
245
  }
101
245
}
Unexecuted instantiation: LanaiMCCodeEmitter.cpp:llvm::LPAC::lanaiAluCodeToString(unsigned int)
102
103
108
inline static AluCode stringToLanaiAluCode(StringRef S) {
104
108
  return StringSwitch<AluCode>(S)
105
108
      .Case("add", ADD)
106
108
      .Case("addc", ADDC)
107
108
      .Case("sub", SUB)
108
108
      .Case("subb", SUBB)
109
108
      .Case("and", AND)
110
108
      .Case("or", OR)
111
108
      .Case("xor", XOR)
112
108
      .Case("sh", SHL)
113
108
      .Case("srl", SRL)
114
108
      .Case("sha", SRA)
115
108
      .Default(UNKNOWN);
116
108
}
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
Unexecuted instantiation: LanaiISelDAGToDAG.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
Unexecuted instantiation: LanaiMemAluCombiner.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
LanaiAsmParser.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
Line
Count
Source
103
108
inline static AluCode stringToLanaiAluCode(StringRef S) {
104
108
  return StringSwitch<AluCode>(S)
105
108
      .Case("add", ADD)
106
108
      .Case("addc", ADDC)
107
108
      .Case("sub", SUB)
108
108
      .Case("subb", SUBB)
109
108
      .Case("and", AND)
110
108
      .Case("or", OR)
111
108
      .Case("xor", XOR)
112
108
      .Case("sh", SHL)
113
108
      .Case("srl", SRL)
114
108
      .Case("sha", SRA)
115
108
      .Default(UNKNOWN);
116
108
}
Unexecuted instantiation: LanaiInstPrinter.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
Unexecuted instantiation: LanaiMCCodeEmitter.cpp:llvm::LPAC::stringToLanaiAluCode(llvm::StringRef)
117
118
6
inline static AluCode isdToLanaiAluCode(ISD::NodeType Node_type) {
119
6
  switch (Node_type) {
120
6
  case ISD::ADD:
121
1
    return AluCode::ADD;
122
6
  case ISD::ADDE:
123
0
    return AluCode::ADDC;
124
6
  case ISD::SUB:
125
0
    return AluCode::SUB;
126
6
  case ISD::SUBE:
127
0
    return AluCode::SUBB;
128
6
  case ISD::AND:
129
0
    return AluCode::AND;
130
6
  case ISD::OR:
131
2
    return AluCode::OR;
132
6
  case ISD::XOR:
133
0
    return AluCode::XOR;
134
6
  case ISD::SHL:
135
0
    return AluCode::SHL;
136
6
  case ISD::SRL:
137
0
    return AluCode::SRL;
138
6
  case ISD::SRA:
139
0
    return AluCode::SRA;
140
6
  default:
141
3
    return AluCode::UNKNOWN;
142
6
  }
143
6
}
Unexecuted instantiation: LanaiAsmPrinter.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
Unexecuted instantiation: LanaiFrameLowering.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
Unexecuted instantiation: LanaiInstrInfo.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
LanaiISelDAGToDAG.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
Line
Count
Source
118
6
inline static AluCode isdToLanaiAluCode(ISD::NodeType Node_type) {
119
6
  switch (Node_type) {
120
6
  case ISD::ADD:
121
1
    return AluCode::ADD;
122
6
  case ISD::ADDE:
123
0
    return AluCode::ADDC;
124
6
  case ISD::SUB:
125
0
    return AluCode::SUB;
126
6
  case ISD::SUBE:
127
0
    return AluCode::SUBB;
128
6
  case ISD::AND:
129
0
    return AluCode::AND;
130
6
  case ISD::OR:
131
2
    return AluCode::OR;
132
6
  case ISD::XOR:
133
0
    return AluCode::XOR;
134
6
  case ISD::SHL:
135
0
    return AluCode::SHL;
136
6
  case ISD::SRL:
137
0
    return AluCode::SRL;
138
6
  case ISD::SRA:
139
0
    return AluCode::SRA;
140
6
  default:
141
3
    return AluCode::UNKNOWN;
142
6
  }
143
6
}
Unexecuted instantiation: LanaiMemAluCombiner.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
Unexecuted instantiation: LanaiRegisterInfo.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
Unexecuted instantiation: LanaiAsmParser.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
Unexecuted instantiation: LanaiInstPrinter.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
Unexecuted instantiation: LanaiMCCodeEmitter.cpp:llvm::LPAC::isdToLanaiAluCode(llvm::ISD::NodeType)
144
} // namespace LPAC
145
} // namespace llvm
146
147
#endif // LLVM_LIB_TARGET_LANAI_LANAIALUCODE_H