Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/Mips/MCTargetDesc/MipsABIFlagsSection.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- MipsABIFlagsSection.cpp - Mips ELF ABI Flags Section ---------------===//
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
#include "MCTargetDesc/MipsABIFlagsSection.h"
10
#include "llvm/ADT/StringRef.h"
11
#include "llvm/MC/MCStreamer.h"
12
#include "llvm/Support/ErrorHandling.h"
13
#include "llvm/Support/MipsABIFlags.h"
14
15
using namespace llvm;
16
17
542
uint8_t MipsABIFlagsSection::getFpABIValue() {
18
542
  switch (FpABI) {
19
542
  case FpABIKind::ANY:
20
0
    return Mips::Val_GNU_MIPS_ABI_FP_ANY;
21
542
  case FpABIKind::SOFT:
22
1
    return Mips::Val_GNU_MIPS_ABI_FP_SOFT;
23
542
  case FpABIKind::XX:
24
5
    return Mips::Val_GNU_MIPS_ABI_FP_XX;
25
542
  case FpABIKind::S32:
26
260
    return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;
27
542
  case FpABIKind::S64:
28
276
    if (Is32BitABI)
29
60
      return OddSPReg ? 
Mips::Val_GNU_MIPS_ABI_FP_6458
30
60
                      : 
Mips::Val_GNU_MIPS_ABI_FP_64A2
;
31
216
    return Mips::Val_GNU_MIPS_ABI_FP_DOUBLE;
32
0
  }
33
0
34
0
  llvm_unreachable("unexpected fp abi value");
35
0
}
36
37
420
StringRef MipsABIFlagsSection::getFpABIString(FpABIKind Value) {
38
420
  switch (Value) {
39
420
  case FpABIKind::XX:
40
15
    return "xx";
41
420
  case FpABIKind::S32:
42
38
    return "32";
43
420
  case FpABIKind::S64:
44
367
    return "64";
45
420
  default:
46
0
    llvm_unreachable("unsupported fp abi value");
47
420
  }
48
420
}
49
50
542
uint8_t MipsABIFlagsSection::getCPR1SizeValue() {
51
542
  if (FpABI == FpABIKind::XX)
52
5
    return (uint8_t)Mips::AFL_REG_32;
53
537
  return (uint8_t)CPR1Size;
54
537
}
55
56
namespace llvm {
57
58
542
MCStreamer &operator<<(MCStreamer &OS, MipsABIFlagsSection &ABIFlagsSection) {
59
542
  // Write out a Elf_Internal_ABIFlags_v0 struct
60
542
  OS.EmitIntValue(ABIFlagsSection.getVersionValue(), 2);      // version
61
542
  OS.EmitIntValue(ABIFlagsSection.getISALevelValue(), 1);     // isa_level
62
542
  OS.EmitIntValue(ABIFlagsSection.getISARevisionValue(), 1);  // isa_rev
63
542
  OS.EmitIntValue(ABIFlagsSection.getGPRSizeValue(), 1);      // gpr_size
64
542
  OS.EmitIntValue(ABIFlagsSection.getCPR1SizeValue(), 1);     // cpr1_size
65
542
  OS.EmitIntValue(ABIFlagsSection.getCPR2SizeValue(), 1);     // cpr2_size
66
542
  OS.EmitIntValue(ABIFlagsSection.getFpABIValue(), 1);        // fp_abi
67
542
  OS.EmitIntValue(ABIFlagsSection.getISAExtensionValue(), 4); // isa_ext
68
542
  OS.EmitIntValue(ABIFlagsSection.getASESetValue(), 4);       // ases
69
542
  OS.EmitIntValue(ABIFlagsSection.getFlags1Value(), 4);       // flags1
70
542
  OS.EmitIntValue(ABIFlagsSection.getFlags2Value(), 4);       // flags2
71
542
  return OS;
72
542
}
73
74
} // end namespace llvm