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

Side by Side Diff: src/IceTargetLoweringX8664Traits.h

Issue 1273153002: Subzero. Native 64-bit int arithmetic on x86-64. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 5 years, 4 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
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8664Traits.h - x86-64 traits -*- C++ -*-=// 1 //===- subzero/src/IceTargetLoweringX8664Traits.h - x86-64 traits -*- C++ -*-=//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
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 /// \file 10 /// \file
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 using GPRRegister = ::Ice::RegX8664::GPRRegister; 60 using GPRRegister = ::Ice::RegX8664::GPRRegister;
61 using XmmRegister = ::Ice::RegX8664::XmmRegister; 61 using XmmRegister = ::Ice::RegX8664::XmmRegister;
62 using ByteRegister = ::Ice::RegX8664::ByteRegister; 62 using ByteRegister = ::Ice::RegX8664::ByteRegister;
63 63
64 using Cond = ::Ice::CondX8664; 64 using Cond = ::Ice::CondX8664;
65 65
66 using RegisterSet = ::Ice::RegX8664; 66 using RegisterSet = ::Ice::RegX8664;
67 static const GPRRegister Encoded_Reg_Accumulator = RegX8664::Encoded_Reg_eax; 67 static const GPRRegister Encoded_Reg_Accumulator = RegX8664::Encoded_Reg_eax;
68 static const GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx; 68 static const GPRRegister Encoded_Reg_Counter = RegX8664::Encoded_Reg_ecx;
69 static const FixupKind PcRelFixup = llvm::ELF::R_386_PC32; // TODO(jpp): ??? 69 static const FixupKind PcRelFixup = llvm::ELF::R_X86_64_PC32;
70 static const FixupKind RelFixup = llvm::ELF::R_X86_64_32S;
70 71
71 class Operand { 72 class Operand {
72 public: 73 public:
73 enum RexBits { 74 enum RexBits {
74 RexNone = 0x00, 75 RexNone = 0x00,
75 RexBase = 0x40, 76 RexBase = 0x40,
76 RexW = RexBase | (1 << 3), 77 RexW = RexBase | (1 << 3),
77 RexR = RexBase | (1 << 2), 78 RexR = RexBase | (1 << 2),
78 RexX = RexBase | (1 << 1), 79 RexX = RexBase | (1 << 1),
79 RexB = RexBase | (1 << 0), 80 RexB = RexBase | (1 << 0),
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 SetFixup(Fixup); 264 SetFixup(Fixup);
264 } 265 }
265 266
266 // TODO(jpp): remove this. 267 // TODO(jpp): remove this.
267 static Address Absolute(RelocOffsetT Offset, AssemblerFixup *Fixup) { 268 static Address Absolute(RelocOffsetT Offset, AssemblerFixup *Fixup) {
268 return Address(ABSOLUTE, Offset, Fixup); 269 return Address(ABSOLUTE, Offset, Fixup);
269 } 270 }
270 271
271 static Address ofConstPool(Assembler *Asm, const Constant *Imm) { 272 static Address ofConstPool(Assembler *Asm, const Constant *Imm) {
272 // TODO(jpp): ??? 273 // TODO(jpp): ???
273 AssemblerFixup *Fixup = Asm->createFixup(llvm::ELF::R_386_32, Imm); 274 AssemblerFixup *Fixup = Asm->createFixup(RelFixup, Imm);
274 const RelocOffsetT Offset = 0; 275 const RelocOffsetT Offset = 4;
275 return Address(ABSOLUTE, Offset, Fixup); 276 return Address(ABSOLUTE, Offset, Fixup);
276 } 277 }
277 }; 278 };
278 279
279 //---------------------------------------------------------------------------- 280 //----------------------------------------------------------------------------
280 // __ ______ __ __ ______ ______ __ __ __ ______ 281 // __ ______ __ __ ______ ______ __ __ __ ______
281 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\ 282 // /\ \ /\ __ \/\ \ _ \ \/\ ___\/\ == \/\ \/\ "-.\ \/\ ___\
282 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \ 283 // \ \ \___\ \ \/\ \ \ \/ ".\ \ \ __\\ \ __<\ \ \ \ \-. \ \ \__ \
283 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\ 284 // \ \_____\ \_____\ \__/".~\_\ \_____\ \_\ \_\ \_\ \_\\"\_\ \_____\
284 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/ 285 // \/_____/\/_____/\/_/ \/_/\/_____/\/_/ /_/\/_/\/_/ \/_/\/_____/
285 // 286 //
286 //---------------------------------------------------------------------------- 287 //----------------------------------------------------------------------------
287 enum InstructionSet { 288 enum InstructionSet {
288 Begin, 289 Begin,
289 // SSE2 is the PNaCl baseline instruction set. 290 // SSE2 is the PNaCl baseline instruction set.
290 SSE2 = Begin, 291 SSE2 = Begin,
291 SSE4_1, 292 SSE4_1,
292 End 293 End
293 }; 294 };
294 295
295 static const char *TargetName; 296 static const char *TargetName;
297 static constexpr Type WordType = IceType_i64;
296 298
297 static IceString getRegName(SizeT RegNum, Type Ty) { 299 static IceString getRegName(SizeT RegNum, Type Ty) {
298 assert(RegNum < RegisterSet::Reg_NUM); 300 assert(RegNum < RegisterSet::Reg_NUM);
299 static const struct { 301 static const struct {
300 const char *const Name8; 302 const char *const Name8;
301 const char *const Name16; 303 const char *const Name16;
302 const char *const Name /*32*/; 304 const char *const Name /*32*/;
303 const char *const Name64; 305 const char *const Name64;
304 } RegNames[] = { 306 } RegNames[] = {
305 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, \ 307 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, \
(...skipping 18 matching lines...) Expand all
324 } 326 }
325 327
326 static void initRegisterSet(llvm::SmallBitVector *IntegerRegisters, 328 static void initRegisterSet(llvm::SmallBitVector *IntegerRegisters,
327 llvm::SmallBitVector *IntegerRegistersI8, 329 llvm::SmallBitVector *IntegerRegistersI8,
328 llvm::SmallBitVector *FloatRegisters, 330 llvm::SmallBitVector *FloatRegisters,
329 llvm::SmallBitVector *VectorRegisters, 331 llvm::SmallBitVector *VectorRegisters,
330 llvm::SmallBitVector *ScratchRegs) { 332 llvm::SmallBitVector *ScratchRegs) {
331 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, \ 333 #define X(val, encode, name64, name32, name16, name8, scratch, preserved, \
332 stackptr, frameptr, isInt, isFP) \ 334 stackptr, frameptr, isInt, isFP) \
333 (*IntegerRegisters)[RegisterSet::val] = isInt; \ 335 (*IntegerRegisters)[RegisterSet::val] = isInt; \
334 (*IntegerRegistersI8)[RegisterSet::val] = 1; \ 336 (*IntegerRegistersI8)[RegisterSet::val] = isInt; \
335 (*FloatRegisters)[RegisterSet::val] = isFP; \ 337 (*FloatRegisters)[RegisterSet::val] = isFP; \
336 (*VectorRegisters)[RegisterSet::val] = isFP; \ 338 (*VectorRegisters)[RegisterSet::val] = isFP; \
337 (*ScratchRegs)[RegisterSet::val] = scratch; 339 (*ScratchRegs)[RegisterSet::val] = scratch;
338 REGX8664_TABLE; 340 REGX8664_TABLE;
339 #undef X 341 #undef X
340 } 342 }
341 343
342 static llvm::SmallBitVector 344 static llvm::SmallBitVector
343 getRegisterSet(TargetLowering::RegSetMask Include, 345 getRegisterSet(TargetLowering::RegSetMask Include,
344 TargetLowering::RegSetMask Exclude) { 346 TargetLowering::RegSetMask Exclude) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 /// The maximum number of arguments to pass in GPR registers 445 /// The maximum number of arguments to pass in GPR registers
444 static const uint32_t X86_MAX_GPR_ARGS = 6; 446 static const uint32_t X86_MAX_GPR_ARGS = 6;
445 /// The number of bits in a byte 447 /// The number of bits in a byte
446 static const uint32_t X86_CHAR_BIT = 8; 448 static const uint32_t X86_CHAR_BIT = 8;
447 /// Stack alignment. This is defined in IceTargetLoweringX8664.cpp because it 449 /// Stack alignment. This is defined in IceTargetLoweringX8664.cpp because it
448 /// is used as an argument to std::max(), and the default std::less<T> has an 450 /// is used as an argument to std::max(), and the default std::less<T> has an
449 /// operator(T const&, T const&) which requires this member to have an 451 /// operator(T const&, T const&) which requires this member to have an
450 /// address. 452 /// address.
451 static const uint32_t X86_STACK_ALIGNMENT_BYTES; 453 static const uint32_t X86_STACK_ALIGNMENT_BYTES;
452 /// Size of the return address on the stack 454 /// Size of the return address on the stack
453 static const uint32_t X86_RET_IP_SIZE_BYTES = 4; 455 static const uint32_t X86_RET_IP_SIZE_BYTES = 8;
454 /// The number of different NOP instructions 456 /// The number of different NOP instructions
455 static const uint32_t X86_NUM_NOP_VARIANTS = 5; 457 static const uint32_t X86_NUM_NOP_VARIANTS = 5;
456 458
457 /// Value is in bytes. Return Value adjusted to the next highest multiple 459 /// Value is in bytes. Return Value adjusted to the next highest multiple
458 /// of the stack alignment. 460 /// of the stack alignment.
459 static uint32_t applyStackAlignment(uint32_t Value) { 461 static uint32_t applyStackAlignment(uint32_t Value) {
460 return Utils::applyAlignment(Value, X86_STACK_ALIGNMENT_BYTES); 462 return Utils::applyAlignment(Value, X86_STACK_ALIGNMENT_BYTES);
461 } 463 }
462 464
463 /// Return the type which the elements of the vector have in the X86 465 /// Return the type which the elements of the vector have in the X86
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 711
710 } // end of namespace X86Internal 712 } // end of namespace X86Internal
711 713
712 namespace X8664 { 714 namespace X8664 {
713 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>; 715 using Traits = ::Ice::X86Internal::MachineTraits<TargetX8664>;
714 } // end of namespace X8664 716 } // end of namespace X8664
715 717
716 } // end of namespace Ice 718 } // end of namespace Ice
717 719
718 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H 720 #endif // SUBZERO_SRC_ICETARGETLOWERINGX8664TRAITS_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698