Skip to content

Commit 77c4141

Browse files
committed
MC: Sketch some TargetAsmBackend hooks we are going to need.
llvm-svn: 98221
1 parent 245f5b2 commit 77c4141

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

llvm/include/llvm/Target/TargetAsmBackend.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@ class TargetAsmBackend {
2828

2929
const Target &getTarget() const { return TheTarget; }
3030

31+
/// hasAbsolutizedSet - Check whether this target "absolutizes"
32+
/// assignments. That is, given code like:
33+
/// a:
34+
/// ...
35+
/// b:
36+
/// tmp = a - b
37+
/// .long tmp
38+
/// will the value of 'tmp' be a relocatable expression, or the assembly time
39+
/// value of L0 - L1. This distinction is only relevant for platforms that
40+
/// support scattered symbols, since in the absence of scattered symbols (a -
41+
/// b) cannot change after assembly.
42+
virtual bool hasAbsolutizedSet() const { return false; }
43+
44+
/// hasScatteredSymbols - Check whether this target supports scattered
45+
/// symbols. If so, the assembler should assume that atoms can be scattered by
46+
/// the linker. In particular, this means that the offsets between symbols
47+
/// which are in distinct atoms is not known at link time, and the assembler
48+
/// must generate fixups and relocations appropriately.
49+
///
50+
/// Note that the assembler currently does not reason about atoms, instead it
51+
/// assumes all temporary symbols reside in the "current atom".
52+
virtual bool hasScatteredSymbols() const { return false; }
3153
};
3254

3355
} // End llvm namespace

llvm/lib/Target/X86/X86AsmBackend.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,34 @@ class X86AsmBackend : public TargetAsmBackend {
2121
: TargetAsmBackend(T) {}
2222
};
2323

24+
class DarwinX86AsmBackend : public X86AsmBackend {
25+
public:
26+
DarwinX86AsmBackend(const Target &T)
27+
: X86AsmBackend(T) {}
28+
29+
virtual bool hasAbsolutizedSet() const { return true; }
30+
31+
virtual bool hasScatteredSymbols() const { return true; }
32+
};
33+
2434
}
2535

2636
TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
2737
const std::string &TT) {
28-
return new X86AsmBackend(T);
38+
switch (Triple(TT).getOS()) {
39+
case Triple::Darwin:
40+
return new DarwinX86AsmBackend(T);
41+
default:
42+
return new X86AsmBackend(T);
43+
}
2944
}
3045

3146
TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
3247
const std::string &TT) {
33-
return new X86AsmBackend(T);
48+
switch (Triple(TT).getOS()) {
49+
case Triple::Darwin:
50+
return new DarwinX86AsmBackend(T);
51+
default:
52+
return new X86AsmBackend(T);
53+
}
3454
}

0 commit comments

Comments
 (0)