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

Side by Side Diff: src/assembler_ia32.cpp

Issue 673543002: First pass at emitIAS for branches and binding labels (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: check the local labels too Created 6 years, 2 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 | « src/assembler_ia32.h ('k') | tests_lit/assembler/x86/jump_encodings.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/assembler_ia32.cpp - Assembler for x86-32 -------------===// 1 //===- subzero/src/assembler_ia32.cpp - Assembler for x86-32 -------------===//
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 // 5 //
6 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // The Subzero Code Generator 10 // The Subzero Code Generator
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 StrBuf << "L$" << Ty << "$" << Imm->getPoolEntryID(); 60 StrBuf << "L$" << Ty << "$" << Imm->getPoolEntryID();
61 const RelocOffsetT Offset = 0; 61 const RelocOffsetT Offset = 0;
62 const bool SuppressMangling = true; 62 const bool SuppressMangling = true;
63 Constant *Sym = 63 Constant *Sym =
64 Ctx->getConstantSym(Ty, Offset, StrBuf.str(), SuppressMangling); 64 Ctx->getConstantSym(Ty, Offset, StrBuf.str(), SuppressMangling);
65 AssemblerFixup *Fixup = x86::DisplacementRelocation::create( 65 AssemblerFixup *Fixup = x86::DisplacementRelocation::create(
66 Asm, FK_Abs_4, llvm::cast<ConstantRelocatable>(Sym)); 66 Asm, FK_Abs_4, llvm::cast<ConstantRelocatable>(Sym));
67 return x86::Address::Absolute(Fixup); 67 return x86::Address::Absolute(Fixup);
68 } 68 }
69 69
70 AssemblerX86::~AssemblerX86() {
71 #ifndef NDEBUG
72 for (const Label *Label : CfgNodeLabels) {
73 Label->FinalCheck();
74 }
75 for (const Label *Label : LocalLabels) {
76 Label->FinalCheck();
77 }
78 #endif
79 }
80
81 Label *AssemblerX86::GetOrCreateLabel(SizeT Number, LabelVector &Labels) {
82 Label *L = nullptr;
83 if (Number == Labels.size()) {
84 L = new (this->Allocate<Label>()) Label();
85 Labels.push_back(L);
86 return L;
87 }
88 if (Number > Labels.size()) {
89 Labels.resize(Number + 1);
90 }
91 L = Labels[Number];
92 if (!L) {
93 L = new (this->Allocate<Label>()) Label();
94 Labels[Number] = L;
95 }
96 return L;
97 }
98
99 Label *AssemblerX86::GetOrCreateCfgNodeLabel(SizeT NodeNumber) {
100 return GetOrCreateLabel(NodeNumber, CfgNodeLabels);
101 }
102
103 Label *AssemblerX86::GetOrCreateLocalLabel(SizeT Number) {
104 return GetOrCreateLabel(Number, LocalLabels);
105 }
106
107 void AssemblerX86::BindCfgNodeLabel(SizeT NodeNumber) {
108 Label *L = GetOrCreateCfgNodeLabel(NodeNumber);
109 this->Bind(L);
110 }
111
112 void AssemblerX86::BindLocalLabel(SizeT Number) {
113 Label *L = GetOrCreateLocalLabel(Number);
114 this->Bind(L);
115 }
116
70 void AssemblerX86::call(GPRRegister reg) { 117 void AssemblerX86::call(GPRRegister reg) {
71 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 118 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
72 EmitUint8(0xFF); 119 EmitUint8(0xFF);
73 EmitRegisterOperand(2, reg); 120 EmitRegisterOperand(2, reg);
74 } 121 }
75 122
76 void AssemblerX86::call(const Address &address) { 123 void AssemblerX86::call(const Address &address) {
77 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 124 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
78 EmitUint8(0xFF); 125 EmitUint8(0xFF);
79 EmitOperand(2, address); 126 EmitOperand(2, address);
(...skipping 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 assert(shifter == RegX8632::Encoded_Reg_ecx); 2521 assert(shifter == RegX8632::Encoded_Reg_ecx);
2475 (void)shifter; 2522 (void)shifter;
2476 if (Ty == IceType_i16) 2523 if (Ty == IceType_i16)
2477 EmitOperandSizeOverride(); 2524 EmitOperandSizeOverride();
2478 EmitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3); 2525 EmitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3);
2479 EmitOperand(rm, operand); 2526 EmitOperand(rm, operand);
2480 } 2527 }
2481 2528
2482 } // end of namespace x86 2529 } // end of namespace x86
2483 } // end of namespace Ice 2530 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/assembler_ia32.h ('k') | tests_lit/assembler/x86/jump_encodings.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698