Skip to content

Commit 7e844e9

Browse files
committed
[M68k] implement large code model
1 parent 439d7de commit 7e844e9

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

llvm/lib/Target/M68k/M68kSubtarget.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ M68kSubtarget &M68kSubtarget::initializeSubtargetDependencies(
127127
// ---------------------+------------+------------+------------+-------------
128128
// data global big* | pc-rel | @GOTPCREL | absolute | @GOTPCREL
129129
// ---------------------+------------+------------+------------+-------------
130+
// | Large |
131+
// +-------------------------+
132+
// | Static | PIC |
133+
// ---------------------+------------+------------+
134+
// branch | pc-rel | pc-rel |
135+
// ---------------------+------------+------------+
136+
// call global | @PLT | @PLT |
137+
// ---------------------+------------+------------+
138+
// call internal | pc-rel | pc-rel |
139+
// ---------------------+------------+------------+
140+
// data local | absolute | @GOTOFF |
141+
// ---------------------+------------+------------+
142+
// data local big* | absolute | @GOTOFF |
143+
// ---------------------+------------+------------+
144+
// data global | absolute | @GOTPCREL |
145+
// ---------------------+------------+------------+
146+
// data global big* | absolute | @GOTPCREL |
147+
// ---------------------+------------+------------+
130148
//
131149
// * Big data potentially cannot be reached within 16 bit offset and requires
132150
// special handling for old(x00 and x10) CPUs. Normally these symbols go into
@@ -171,6 +189,13 @@ M68kSubtarget::classifyLocalReference(const GlobalValue *GV) const {
171189
return M68kII::MO_ABSOLUTE_ADDRESS;
172190
}
173191
}
192+
case CodeModel::Large: {
193+
if (isPositionIndependent()) {
194+
return M68kII::MO_GOTOFF;
195+
} else {
196+
return M68kII::MO_ABSOLUTE_ADDRESS;
197+
}
198+
}
174199
}
175200
}
176201

@@ -212,6 +237,12 @@ unsigned char M68kSubtarget::classifyGlobalReference(const GlobalValue *GV,
212237

213238
return M68kII::MO_ABSOLUTE_ADDRESS;
214239
}
240+
case CodeModel::Large: {
241+
if (isPositionIndependent())
242+
return M68kII::MO_GOTPCREL;
243+
244+
return M68kII::MO_ABSOLUTE_ADDRESS;
245+
}
215246
}
216247
}
217248

llvm/lib/Target/M68k/M68kTargetMachine.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ CodeModel::Model getEffectiveCodeModel(std::optional<CodeModel::Model> CM,
8787
bool JIT) {
8888
if (!CM) {
8989
return CodeModel::Small;
90-
} else if (CM == CodeModel::Large) {
91-
llvm_unreachable("Large code model is not supported");
9290
} else if (CM == CodeModel::Kernel) {
9391
llvm_unreachable("Kernel code model is not implemented yet");
9492
}

0 commit comments

Comments
 (0)