Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.cpp
Line
Count
Source
1
#include "RISCVBaseInfo.h"
2
#include "llvm/ADT/ArrayRef.h"
3
#include "llvm/ADT/Triple.h"
4
#include "llvm/Support/raw_ostream.h"
5
6
namespace llvm {
7
namespace RISCVSysReg {
8
#define GET_SysRegsList_IMPL
9
#include "RISCVGenSystemOperands.inc"
10
} // namespace RISCVSysReg
11
12
namespace RISCVABI {
13
ABI computeTargetABI(const Triple &TT, FeatureBitset FeatureBits,
14
1.12k
                     StringRef ABIName) {
15
1.12k
  auto TargetABI = StringSwitch<ABI>(ABIName)
16
1.12k
                       .Case("ilp32", ABI_ILP32)
17
1.12k
                       .Case("ilp32f", ABI_ILP32F)
18
1.12k
                       .Case("ilp32d", ABI_ILP32D)
19
1.12k
                       .Case("ilp32e", ABI_ILP32E)
20
1.12k
                       .Case("lp64", ABI_LP64)
21
1.12k
                       .Case("lp64f", ABI_LP64F)
22
1.12k
                       .Case("lp64d", ABI_LP64D)
23
1.12k
                       .Default(ABI_Unknown);
24
1.12k
25
1.12k
  bool IsRV64 = TT.isArch64Bit();
26
1.12k
  bool IsRV32E = FeatureBits[RISCV::FeatureRV32E];
27
1.12k
28
1.12k
  if (!ABIName.empty() && 
TargetABI == ABI_Unknown161
) {
29
6
    errs()
30
6
        << "'" << ABIName
31
6
        << "' is not a recognized ABI for this target (ignoring target-abi)\n";
32
1.11k
  } else if (ABIName.startswith("ilp32") && 
IsRV6493
) {
33
18
    errs() << "32-bit ABIs are not supported for 64-bit targets (ignoring "
34
18
              "target-abi)\n";
35
18
    TargetABI = ABI_Unknown;
36
1.09k
  } else if (ABIName.startswith("lp64") && 
!IsRV6462
) {
37
12
    errs() << "64-bit ABIs are not supported for 32-bit targets (ignoring "
38
12
              "target-abi)\n";
39
12
    TargetABI = ABI_Unknown;
40
1.08k
  } else if (ABIName.endswith("f") && 
!FeatureBits[RISCV::FeatureStdExtF]53
) {
41
6
    errs() << "Hard-float 'f' ABI can't be used for a target that "
42
6
              "doesn't support the F instruction set extension (ignoring "
43
6
              "target-abi)\n";
44
6
    TargetABI = ABI_Unknown;
45
1.07k
  } else if (ABIName.endswith("d") && 
!FeatureBits[RISCV::FeatureStdExtD]49
) {
46
12
    errs() << "Hard-float 'd' ABI can't be used for a target that "
47
12
              "doesn't support the D instruction set extension (ignoring "
48
12
              "target-abi)\n";
49
12
    TargetABI = ABI_Unknown;
50
1.06k
  } else if (IsRV32E && 
TargetABI != ABI_ILP32E11
&&
TargetABI != ABI_Unknown11
) {
51
4
    errs()
52
4
        << "Only the ilp32e ABI is supported for RV32E (ignoring target-abi)\n";
53
4
    TargetABI = ABI_Unknown;
54
4
  }
55
1.12k
56
1.12k
  if (TargetABI != ABI_Unknown)
57
103
    return TargetABI;
58
1.01k
59
1.01k
  // For now, default to the ilp32/ilp32e/lp64 ABI if no explicit ABI is given
60
1.01k
  // or an invalid/unrecognised string is given. In the future, it might be
61
1.01k
  // worth changing this to default to ilp32f/lp64f and ilp32d/lp64d when
62
1.01k
  // hardware support for floating point is present.
63
1.01k
  if (IsRV32E)
64
14
    return ABI_ILP32E;
65
1.00k
  if (IsRV64)
66
420
    return ABI_LP64;
67
583
  return ABI_ILP32;
68
583
}
69
} // namespace RISCVABI
70
71
namespace RISCVFeatures {
72
73
1.12k
void validate(const Triple &TT, const FeatureBitset &FeatureBits) {
74
1.12k
  if (TT.isArch64Bit() && 
FeatureBits[RISCV::FeatureRV32E]463
)
75
2
    report_fatal_error("RV32E can't be enabled for an RV64 target");
76
1.12k
}
77
78
} // namespace RISCVFeatures
79
80
} // namespace llvm