Deleted Added
full compact
MCAsmInfo.cpp (263508) MCAsmInfo.cpp (266715)
1//===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines target asm properties related what form asm statements
11// should take.
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/MC/MCAsmInfo.h"
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCExpr.h"
18#include "llvm/MC/MCStreamer.h"
19#include "llvm/Support/DataTypes.h"
20#include "llvm/Support/Dwarf.h"
21#include <cctype>
22#include <cstring>
23using namespace llvm;
24
25MCAsmInfo::MCAsmInfo() {
26 PointerSize = 4;
27 CalleeSaveStackSlotSize = 4;
28
29 IsLittleEndian = true;
30 StackGrowsUp = false;
31 HasSubsectionsViaSymbols = false;
32 HasMachoZeroFillDirective = false;
33 HasMachoTBSSDirective = false;
34 HasStaticCtorDtorReferenceInStaticMode = false;
35 LinkerRequiresNonEmptyDwarfLines = false;
36 MaxInstLength = 4;
37 MinInstAlignment = 1;
38 DollarIsPC = false;
39 SeparatorString = ";";
40 CommentColumn = 40;
41 CommentString = "#";
42 LabelSuffix = ":";
43 DebugLabelSuffix = ":";
44 GlobalPrefix = "";
45 PrivateGlobalPrefix = ".";
46 LinkerPrivateGlobalPrefix = "";
47 InlineAsmStart = "APP";
48 InlineAsmEnd = "NO_APP";
49 Code16Directive = ".code16";
50 Code32Directive = ".code32";
51 Code64Directive = ".code64";
52 AssemblerDialect = 0;
53 AllowAtInName = false;
54 UseDataRegionDirectives = false;
55 ZeroDirective = "\t.zero\t";
56 AsciiDirective = "\t.ascii\t";
57 AscizDirective = "\t.asciz\t";
58 Data8bitsDirective = "\t.byte\t";
59 Data16bitsDirective = "\t.short\t";
60 Data32bitsDirective = "\t.long\t";
61 Data64bitsDirective = "\t.quad\t";
62 SunStyleELFSectionSwitchSyntax = false;
63 UsesELFSectionDirectiveForBSS = false;
64 AlignDirective = "\t.align\t";
65 AlignmentIsInBytes = true;
66 TextAlignFillValue = 0;
67 GPRel64Directive = 0;
68 GPRel32Directive = 0;
69 GlobalDirective = "\t.globl\t";
70 HasSetDirective = true;
71 HasAggressiveSymbolFolding = true;
72 COMMDirectiveAlignmentIsInBytes = true;
73 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
74 HasDotTypeDotSizeDirective = true;
75 HasSingleParameterDotFile = true;
76 HasIdentDirective = false;
77 HasNoDeadStrip = false;
78 WeakRefDirective = 0;
1//===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines target asm properties related what form asm statements
11// should take.
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/MC/MCAsmInfo.h"
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCExpr.h"
18#include "llvm/MC/MCStreamer.h"
19#include "llvm/Support/DataTypes.h"
20#include "llvm/Support/Dwarf.h"
21#include <cctype>
22#include <cstring>
23using namespace llvm;
24
25MCAsmInfo::MCAsmInfo() {
26 PointerSize = 4;
27 CalleeSaveStackSlotSize = 4;
28
29 IsLittleEndian = true;
30 StackGrowsUp = false;
31 HasSubsectionsViaSymbols = false;
32 HasMachoZeroFillDirective = false;
33 HasMachoTBSSDirective = false;
34 HasStaticCtorDtorReferenceInStaticMode = false;
35 LinkerRequiresNonEmptyDwarfLines = false;
36 MaxInstLength = 4;
37 MinInstAlignment = 1;
38 DollarIsPC = false;
39 SeparatorString = ";";
40 CommentColumn = 40;
41 CommentString = "#";
42 LabelSuffix = ":";
43 DebugLabelSuffix = ":";
44 GlobalPrefix = "";
45 PrivateGlobalPrefix = ".";
46 LinkerPrivateGlobalPrefix = "";
47 InlineAsmStart = "APP";
48 InlineAsmEnd = "NO_APP";
49 Code16Directive = ".code16";
50 Code32Directive = ".code32";
51 Code64Directive = ".code64";
52 AssemblerDialect = 0;
53 AllowAtInName = false;
54 UseDataRegionDirectives = false;
55 ZeroDirective = "\t.zero\t";
56 AsciiDirective = "\t.ascii\t";
57 AscizDirective = "\t.asciz\t";
58 Data8bitsDirective = "\t.byte\t";
59 Data16bitsDirective = "\t.short\t";
60 Data32bitsDirective = "\t.long\t";
61 Data64bitsDirective = "\t.quad\t";
62 SunStyleELFSectionSwitchSyntax = false;
63 UsesELFSectionDirectiveForBSS = false;
64 AlignDirective = "\t.align\t";
65 AlignmentIsInBytes = true;
66 TextAlignFillValue = 0;
67 GPRel64Directive = 0;
68 GPRel32Directive = 0;
69 GlobalDirective = "\t.globl\t";
70 HasSetDirective = true;
71 HasAggressiveSymbolFolding = true;
72 COMMDirectiveAlignmentIsInBytes = true;
73 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment;
74 HasDotTypeDotSizeDirective = true;
75 HasSingleParameterDotFile = true;
76 HasIdentDirective = false;
77 HasNoDeadStrip = false;
78 WeakRefDirective = 0;
79 WeakDefDirective = 0;
80 LinkOnceDirective = 0;
79 HasWeakDefDirective = false;
80 HasWeakDefCanBeHiddenDirective = false;
81 HasLinkOnceDirective = false;
81 HiddenVisibilityAttr = MCSA_Hidden;
82 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
83 ProtectedVisibilityAttr = MCSA_Protected;
84 HasLEB128 = false;
85 SupportsDebugInformation = false;
86 ExceptionsType = ExceptionHandling::None;
87 DwarfUsesRelocationsAcrossSections = true;
82 HiddenVisibilityAttr = MCSA_Hidden;
83 HiddenDeclarationVisibilityAttr = MCSA_Hidden;
84 ProtectedVisibilityAttr = MCSA_Protected;
85 HasLEB128 = false;
86 SupportsDebugInformation = false;
87 ExceptionsType = ExceptionHandling::None;
88 DwarfUsesRelocationsAcrossSections = true;
89 DwarfFDESymbolsUseAbsDiff = false;
88 DwarfRegNumForCFI = false;
89 HasMicrosoftFastStdCallMangling = false;
90 NeedsDwarfSectionOffsetDirective = false;
91}
92
93MCAsmInfo::~MCAsmInfo() {
94}
95
96
97unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
98 unsigned Size = 0;
99 do {
100 Value >>= 7;
101 Size += sizeof(int8_t);
102 } while (Value);
103 return Size;
104}
105
106unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
107 unsigned Size = 0;
108 int Sign = Value >> (8 * sizeof(Value) - 1);
109 bool IsMore;
110
111 do {
112 unsigned Byte = Value & 0x7f;
113 Value >>= 7;
114 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
115 Size += sizeof(int8_t);
116 } while (IsMore);
117 return Size;
118}
119
120const MCExpr *
121MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
122 unsigned Encoding,
123 MCStreamer &Streamer) const {
124 return getExprForFDESymbol(Sym, Encoding, Streamer);
125}
126
127const MCExpr *
128MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
129 unsigned Encoding,
130 MCStreamer &Streamer) const {
131 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
132 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
133
134 MCContext &Context = Streamer.getContext();
135 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
136 MCSymbol *PCSym = Context.CreateTempSymbol();
137 Streamer.EmitLabel(PCSym);
138 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
139 return MCBinaryExpr::CreateSub(Res, PC, Context);
140}
90 DwarfRegNumForCFI = false;
91 HasMicrosoftFastStdCallMangling = false;
92 NeedsDwarfSectionOffsetDirective = false;
93}
94
95MCAsmInfo::~MCAsmInfo() {
96}
97
98
99unsigned MCAsmInfo::getULEB128Size(uint64_t Value) {
100 unsigned Size = 0;
101 do {
102 Value >>= 7;
103 Size += sizeof(int8_t);
104 } while (Value);
105 return Size;
106}
107
108unsigned MCAsmInfo::getSLEB128Size(int64_t Value) {
109 unsigned Size = 0;
110 int Sign = Value >> (8 * sizeof(Value) - 1);
111 bool IsMore;
112
113 do {
114 unsigned Byte = Value & 0x7f;
115 Value >>= 7;
116 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
117 Size += sizeof(int8_t);
118 } while (IsMore);
119 return Size;
120}
121
122const MCExpr *
123MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
124 unsigned Encoding,
125 MCStreamer &Streamer) const {
126 return getExprForFDESymbol(Sym, Encoding, Streamer);
127}
128
129const MCExpr *
130MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
131 unsigned Encoding,
132 MCStreamer &Streamer) const {
133 if (!(Encoding & dwarf::DW_EH_PE_pcrel))
134 return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
135
136 MCContext &Context = Streamer.getContext();
137 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context);
138 MCSymbol *PCSym = Context.CreateTempSymbol();
139 Streamer.EmitLabel(PCSym);
140 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context);
141 return MCBinaryExpr::CreateSub(Res, PC, Context);
142}