Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: lib/Target/X86/X86Subtarget.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Target/X86/X86Subtarget.h ('k') | lib/Target/X86/X86TargetMachine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- X86Subtarget.cpp - X86 Subtarget Information ----------------------===// 1 //===-- X86Subtarget.cpp - X86 Subtarget Information ----------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the X86 specific subclass of TargetSubtargetInfo. 10 // This file implements the X86 specific subclass of TargetSubtargetInfo.
(...skipping 26 matching lines...) Expand all
37 #define GET_SUBTARGETINFO_CTOR 37 #define GET_SUBTARGETINFO_CTOR
38 #include "X86GenSubtargetInfo.inc" 38 #include "X86GenSubtargetInfo.inc"
39 39
40 // Temporary option to control early if-conversion for x86 while adding machine 40 // Temporary option to control early if-conversion for x86 while adding machine
41 // models. 41 // models.
42 static cl::opt<bool> 42 static cl::opt<bool>
43 X86EarlyIfConv("x86-early-ifcvt", cl::Hidden, 43 X86EarlyIfConv("x86-early-ifcvt", cl::Hidden,
44 cl::desc("Enable early if-conversion on X86")); 44 cl::desc("Enable early if-conversion on X86"));
45 45
46 46
47 // @LOCALMOD-START
48 static cl::opt<bool>
49 MalignDouble("malign-double", cl::Hidden,
50 cl::desc("Align i64 and f64 types to 8 bytes"));
51 // @LOCALMOD-END
52
53
47 /// ClassifyBlockAddressReference - Classify a blockaddress reference for the 54 /// ClassifyBlockAddressReference - Classify a blockaddress reference for the
48 /// current subtarget according to how we should reference it in a non-pcrel 55 /// current subtarget according to how we should reference it in a non-pcrel
49 /// context. 56 /// context.
50 unsigned char X86Subtarget::ClassifyBlockAddressReference() const { 57 unsigned char X86Subtarget::ClassifyBlockAddressReference() const {
51 if (isPICStyleGOT()) // 32-bit ELF targets. 58 if (isPICStyleGOT()) // 32-bit ELF targets.
52 return X86II::MO_GOTOFF; 59 return X86II::MO_GOTOFF;
53 60
54 if (isPICStyleStubPIC()) // Darwin/32 in PIC mode. 61 if (isPICStyleStubPIC()) // Darwin/32 in PIC mode.
55 return X86II::MO_PIC_BASE_OFFSET; 62 return X86II::MO_PIC_BASE_OFFSET;
56 63
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 175 }
169 176
170 /// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls 177 /// IsLegalToCallImmediateAddr - Return true if the subtarget allows calls
171 /// to immediate address. 178 /// to immediate address.
172 bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const { 179 bool X86Subtarget::IsLegalToCallImmediateAddr(const TargetMachine &TM) const {
173 // FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32 180 // FIXME: I386 PE/COFF supports PC relative calls using IMAGE_REL_I386_REL32
174 // but WinCOFFObjectWriter::RecordRelocation cannot emit them. Once it does, 181 // but WinCOFFObjectWriter::RecordRelocation cannot emit them. Once it does,
175 // the following check for Win32 should be removed. 182 // the following check for Win32 should be removed.
176 if (In64BitMode || isTargetWin32()) 183 if (In64BitMode || isTargetWin32())
177 return false; 184 return false;
178 return isTargetELF() || TM.getRelocationModel() == Reloc::Static; 185 // @LOCALMOD-BEGIN
186 // BUG= http://code.google.com/p/nativeclient/issues/detail?id=2367
187 // For NaCl dynamic linking we do not want to generate a text relocation to
188 // an absolute address in PIC mode. Such a situation arises from
189 // test/CodeGen/X86/call-imm.ll with the default implementation.
190 // For other platforms we retain the default behavior.
191 return (isTargetELF() && !isTargetNaCl()) ||
192 TM.getRelocationModel() == Reloc::Static;
193 // @LOCALMOD-END
179 } 194 }
180 195
181 void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { 196 void X86Subtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
182 std::string CPUName = CPU; 197 std::string CPUName = CPU;
183 if (CPUName.empty()) 198 if (CPUName.empty())
184 CPUName = "generic"; 199 CPUName = "generic";
185 200
186 // Make sure 64-bit features are available in 64-bit mode. (But make sure 201 // Make sure 64-bit features are available in 64-bit mode. (But make sure
187 // SSE2 can be turned off explicitly.) 202 // SSE2 can be turned off explicitly.)
188 std::string FullFS = FS; 203 std::string FullFS = FS;
(...skipping 23 matching lines...) Expand all
212 else 227 else
213 llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!"); 228 llvm_unreachable("Not 16-bit, 32-bit or 64-bit mode!");
214 229
215 DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel 230 DEBUG(dbgs() << "Subtarget features: SSELevel " << X86SSELevel
216 << ", 3DNowLevel " << X863DNowLevel 231 << ", 3DNowLevel " << X863DNowLevel
217 << ", 64bit " << HasX86_64 << "\n"); 232 << ", 64bit " << HasX86_64 << "\n");
218 assert((!In64BitMode || HasX86_64) && 233 assert((!In64BitMode || HasX86_64) &&
219 "64-bit code requested on a subtarget that doesn't support it!"); 234 "64-bit code requested on a subtarget that doesn't support it!");
220 235
221 // Stack alignment is 16 bytes on Darwin, Linux and Solaris (both 236 // Stack alignment is 16 bytes on Darwin, Linux and Solaris (both
222 // 32 and 64 bit) and for all 64-bit targets. 237 // 32 and 64 bit), NaCl and for all 64-bit targets.
223 if (StackAlignOverride) 238 if (StackAlignOverride)
224 stackAlignment = StackAlignOverride; 239 stackAlignment = StackAlignOverride;
225 else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() || 240 else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
241 isTargetNaCl() || // @LOCALMOD
226 In64BitMode) 242 In64BitMode)
227 stackAlignment = 16; 243 stackAlignment = 16;
228 } 244 }
229 245
230 void X86Subtarget::initializeEnvironment() { 246 void X86Subtarget::initializeEnvironment() {
231 X86SSELevel = NoMMXSSE; 247 X86SSELevel = NoMMXSSE;
232 X863DNowLevel = NoThreeDNow; 248 X863DNowLevel = NoThreeDNow;
233 HasCMov = false; 249 HasCMov = false;
234 HasX86_64 = false; 250 HasX86_64 = false;
235 HasPOPCNT = false; 251 HasPOPCNT = false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 std::string Ret = "e"; 303 std::string Ret = "e";
288 304
289 Ret += DataLayout::getManglingComponent(TT); 305 Ret += DataLayout::getManglingComponent(TT);
290 // X86 and x32 have 32 bit pointers. 306 // X86 and x32 have 32 bit pointers.
291 if ((TT.isArch64Bit() && 307 if ((TT.isArch64Bit() &&
292 (TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) || 308 (TT.getEnvironment() == Triple::GNUX32 || TT.isOSNaCl())) ||
293 !TT.isArch64Bit()) 309 !TT.isArch64Bit())
294 Ret += "-p:32:32"; 310 Ret += "-p:32:32";
295 311
296 // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32. 312 // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
297 if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl()) 313 if (TT.isArch64Bit() || TT.isOSWindows() || TT.isOSNaCl()
314 || MalignDouble) // @LOCALMOD
298 Ret += "-i64:64"; 315 Ret += "-i64:64";
299 else 316 else
300 Ret += "-f64:32:64"; 317 Ret += "-f64:32:64";
301 318
302 // Some ABIs align long double to 128 bits, others to 32. 319 // Some ABIs align long double to 128 bits, others to 32.
303 if (TT.isOSNaCl()) 320 // @LOCALMOD Removed the NaCl special-casing for LLVM 3.5 merge, it was
304 ; // No f80 321 // wrong. Patch sent upstream.
305 else if (TT.isArch64Bit() || TT.isOSDarwin()) 322 if (TT.isArch64Bit() || TT.isOSDarwin())
306 Ret += "-f80:128"; 323 Ret += "-f80:128";
307 else 324 else
308 Ret += "-f80:32"; 325 Ret += "-f80:32";
309 326
310 // The registers can hold 8, 16, 32 or, in x86-64, 64 bits. 327 // The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
311 if (TT.isArch64Bit()) 328 if (TT.isArch64Bit())
312 Ret += "-n8:16:32:64"; 329 Ret += "-n8:16:32:64";
313 else 330 else
314 Ret += "-n8:16:32"; 331 Ret += "-n8:16:32";
315 332
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 setPICStyle(PICStyles::StubDynamicNoPIC); 378 setPICStyle(PICStyles::StubDynamicNoPIC);
362 } 379 }
363 } else if (isTargetELF()) { 380 } else if (isTargetELF()) {
364 setPICStyle(PICStyles::GOT); 381 setPICStyle(PICStyles::GOT);
365 } 382 }
366 } 383 }
367 384
368 bool X86Subtarget::enableEarlyIfConversion() const { 385 bool X86Subtarget::enableEarlyIfConversion() const {
369 return hasCMov() && X86EarlyIfConv; 386 return hasCMov() && X86EarlyIfConv;
370 } 387 }
371
OLDNEW
« no previous file with comments | « lib/Target/X86/X86Subtarget.h ('k') | lib/Target/X86/X86TargetMachine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698