Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/lib/Basic/Targets/RISCV.h
Line
Count
Source (jump to first uncovered line)
1
//===--- RISCV.h - Declare RISCV target feature support ---------*- 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
//
9
// This file declares RISCV TargetInfo objects.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
14
#define LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
15
16
#include "clang/Basic/TargetInfo.h"
17
#include "clang/Basic/TargetOptions.h"
18
#include "llvm/ADT/Triple.h"
19
#include "llvm/Support/Compiler.h"
20
21
namespace clang {
22
namespace targets {
23
24
// RISC-V Target
25
class RISCVTargetInfo : public TargetInfo {
26
protected:
27
  std::string ABI;
28
  bool HasM;
29
  bool HasA;
30
  bool HasF;
31
  bool HasD;
32
  bool HasC;
33
34
public:
35
  RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
36
      : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
37
70
        HasD(false), HasC(false) {
38
70
    LongDoubleWidth = 128;
39
70
    LongDoubleAlign = 128;
40
70
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
41
70
    SuitableAlign = 128;
42
70
    WCharType = SignedInt;
43
70
    WIntType = UnsignedInt;
44
70
  }
45
46
100
  StringRef getABI() const override { return ABI; }
47
  void getTargetDefines(const LangOptions &Opts,
48
                        MacroBuilder &Builder) const override;
49
50
68
  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
51
52
45
  BuiltinVaListKind getBuiltinVaListKind() const override {
53
45
    return TargetInfo::VoidPtrBuiltinVaList;
54
45
  }
55
56
10
  const char *getClobbers() const override { return ""; }
57
58
  ArrayRef<const char *> getGCCRegNames() const override;
59
60
8
  int getEHDataRegisterNumber(unsigned RegNo) const override {
61
8
    if (RegNo == 0)
62
4
      return 10;
63
4
    else if (RegNo == 1)
64
4
      return 11;
65
0
    else
66
0
      return -1;
67
8
  }
68
69
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
70
71
  bool validateAsmConstraint(const char *&Name,
72
                             TargetInfo::ConstraintInfo &Info) const override;
73
74
  bool hasFeature(StringRef Feature) const override;
75
76
  bool handleTargetFeatures(std::vector<std::string> &Features,
77
                            DiagnosticsEngine &Diags) override;
78
};
79
class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
80
public:
81
  RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
82
38
      : RISCVTargetInfo(Triple, Opts) {
83
38
    IntPtrType = SignedInt;
84
38
    PtrDiffType = SignedInt;
85
38
    SizeType = UnsignedInt;
86
38
    resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
87
38
  }
clang::targets::RISCV32TargetInfo::RISCV32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
82
25
      : RISCVTargetInfo(Triple, Opts) {
83
25
    IntPtrType = SignedInt;
84
25
    PtrDiffType = SignedInt;
85
25
    SizeType = UnsignedInt;
86
25
    resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
87
25
  }
clang::targets::RISCV32TargetInfo::RISCV32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
82
13
      : RISCVTargetInfo(Triple, Opts) {
83
13
    IntPtrType = SignedInt;
84
13
    PtrDiffType = SignedInt;
85
13
    SizeType = UnsignedInt;
86
13
    resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
87
13
  }
88
89
21
  bool setABI(const std::string &Name) override {
90
21
    if (Name == "ilp32" || 
Name == "ilp32f"10
||
Name == "ilp32d"5
) {
91
20
      ABI = Name;
92
20
      return true;
93
20
    }
94
1
    return false;
95
1
  }
96
};
97
class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
98
public:
99
  RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
100
32
      : RISCVTargetInfo(Triple, Opts) {
101
32
    LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
102
32
    IntMaxType = Int64Type = SignedLong;
103
32
    resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
104
32
  }
clang::targets::RISCV64TargetInfo::RISCV64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
100
22
      : RISCVTargetInfo(Triple, Opts) {
101
22
    LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
102
22
    IntMaxType = Int64Type = SignedLong;
103
22
    resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
104
22
  }
clang::targets::RISCV64TargetInfo::RISCV64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
100
10
      : RISCVTargetInfo(Triple, Opts) {
101
10
    LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
102
10
    IntMaxType = Int64Type = SignedLong;
103
10
    resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
104
10
  }
105
106
17
  bool setABI(const std::string &Name) override {
107
17
    if (Name == "lp64" || 
Name == "lp64f"9
||
Name == "lp64d"5
) {
108
16
      ABI = Name;
109
16
      return true;
110
16
    }
111
1
    return false;
112
1
  }
113
};
114
} // namespace targets
115
} // namespace clang
116
117
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H