Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/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
93
        HasD(false), HasC(false) {
38
93
    LongDoubleWidth = 128;
39
93
    LongDoubleAlign = 128;
40
93
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
41
93
    SuitableAlign = 128;
42
93
    WCharType = SignedInt;
43
93
    WIntType = UnsignedInt;
44
93
  }
45
46
177
  StringRef getABI() const override { return ABI; }
47
  void getTargetDefines(const LangOptions &Opts,
48
                        MacroBuilder &Builder) const override;
49
50
91
  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
51
52
58
  BuiltinVaListKind getBuiltinVaListKind() const override {
53
58
    return TargetInfo::VoidPtrBuiltinVaList;
54
58
  }
55
56
16
  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
50
      : RISCVTargetInfo(Triple, Opts) {
83
50
    IntPtrType = SignedInt;
84
50
    PtrDiffType = SignedInt;
85
50
    SizeType = UnsignedInt;
86
50
    resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
87
50
  }
clang::targets::RISCV32TargetInfo::RISCV32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
82
32
      : RISCVTargetInfo(Triple, Opts) {
83
32
    IntPtrType = SignedInt;
84
32
    PtrDiffType = SignedInt;
85
32
    SizeType = UnsignedInt;
86
32
    resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
87
32
  }
clang::targets::RISCV32TargetInfo::RISCV32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
82
18
      : RISCVTargetInfo(Triple, Opts) {
83
18
    IntPtrType = SignedInt;
84
18
    PtrDiffType = SignedInt;
85
18
    SizeType = UnsignedInt;
86
18
    resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
87
18
  }
88
89
29
  bool setABI(const std::string &Name) override {
90
29
    if (Name == "ilp32" || 
Name == "ilp32f"16
||
Name == "ilp32d"10
) {
91
28
      ABI = Name;
92
28
      return true;
93
28
    }
94
1
    return false;
95
1
  }
96
97
49
  void setMaxAtomicWidth() override {
98
49
    MaxAtomicPromoteWidth = 128;
99
49
100
49
    if (HasA)
101
6
      MaxAtomicInlineWidth = 32;
102
49
  }
103
};
104
class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
105
public:
106
  RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
107
43
      : RISCVTargetInfo(Triple, Opts) {
108
43
    LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
109
43
    IntMaxType = Int64Type = SignedLong;
110
43
    resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
111
43
  }
clang::targets::RISCV64TargetInfo::RISCV64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
107
28
      : RISCVTargetInfo(Triple, Opts) {
108
28
    LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
109
28
    IntMaxType = Int64Type = SignedLong;
110
28
    resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
111
28
  }
clang::targets::RISCV64TargetInfo::RISCV64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
107
15
      : RISCVTargetInfo(Triple, Opts) {
108
15
    LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
109
15
    IntMaxType = Int64Type = SignedLong;
110
15
    resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
111
15
  }
112
113
25
  bool setABI(const std::string &Name) override {
114
25
    if (Name == "lp64" || 
Name == "lp64f"12
||
Name == "lp64d"7
) {
115
24
      ABI = Name;
116
24
      return true;
117
24
    }
118
1
    return false;
119
1
  }
120
121
42
  void setMaxAtomicWidth() override {
122
42
    MaxAtomicPromoteWidth = 128;
123
42
124
42
    if (HasA)
125
3
      MaxAtomicInlineWidth = 64;
126
42
  }
127
};
128
} // namespace targets
129
} // namespace clang
130
131
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H