1 //===- lib/MC/MCSectionWasm.cpp - Wasm Code Section Representation --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCSectionWasm.h"
11 #include "llvm/MC/MCAsmInfo.h"
12 #include "llvm/MC/MCExpr.h"
13 #include "llvm/MC/MCSymbol.h"
14 #include "llvm/Support/raw_ostream.h"
18 MCSectionWasm::~MCSectionWasm() {} // anchor.
20 // Decides whether a '.section' directive
21 // should be printed before the section name.
22 bool MCSectionWasm::ShouldOmitSectionDirective(StringRef Name
,
23 const MCAsmInfo
&MAI
) const {
24 return MAI
.shouldOmitSectionDirective(Name
);
27 static void printName(raw_ostream
&OS
, StringRef Name
) {
28 if (Name
.find_first_not_of("0123456789_."
29 "abcdefghijklmnopqrstuvwxyz"
30 "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == Name
.npos
) {
35 for (const char *B
= Name
.begin(), *E
= Name
.end(); B
< E
; ++B
) {
36 if (*B
== '"') // Unquoted "
38 else if (*B
!= '\\') // Neither " or backslash
40 else if (B
+ 1 == E
) // Trailing backslash
43 OS
<< B
[0] << B
[1]; // Quoted character
50 void MCSectionWasm::PrintSwitchToSection(const MCAsmInfo
&MAI
, const Triple
&T
,
52 const MCExpr
*Subsection
) const {
54 if (ShouldOmitSectionDirective(SectionName
, MAI
)) {
55 OS
<< '\t' << getSectionName();
58 Subsection
->print(OS
, &MAI
);
65 printName(OS
, getSectionName());
68 // TODO: Print section flags.
74 // If comment string is '@', e.g. as on ARM - use '%' instead
75 if (MAI
.getCommentString()[0] == '@')
80 // TODO: Print section type.
83 OS
<< ",unique," << UniqueID
;
88 OS
<< "\t.subsection\t";
89 Subsection
->print(OS
, &MAI
);
94 bool MCSectionWasm::UseCodeAlign() const { return false; }
96 bool MCSectionWasm::isVirtualSection() const { return false; }