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

Side by Side Diff: lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 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/MCTargetDesc/X86MCAsmInfo.cpp ('k') | lib/Target/X86/MCTargetDesc/X86MCNaCl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- X86MCCodeEmitter.cpp - Convert X86 code to machine code -----------===// 1 //===-- X86MCCodeEmitter.cpp - Convert X86 code to machine code -----------===//
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 X86MCCodeEmitter class. 10 // This file implements the X86MCCodeEmitter class.
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 EmitImmediate(Disp, MI.getLoc(), 4, MCFixupKind(X86::reloc_signed_4byte), 583 EmitImmediate(Disp, MI.getLoc(), 4, MCFixupKind(X86::reloc_signed_4byte),
584 CurByte, OS, Fixups); 584 CurByte, OS, Fixups);
585 } 585 }
586 586
587 /// EmitVEXOpcodePrefix - AVX instructions are encoded using a opcode prefix 587 /// EmitVEXOpcodePrefix - AVX instructions are encoded using a opcode prefix
588 /// called VEX. 588 /// called VEX.
589 void X86MCCodeEmitter::EmitVEXOpcodePrefix(uint64_t TSFlags, unsigned &CurByte, 589 void X86MCCodeEmitter::EmitVEXOpcodePrefix(uint64_t TSFlags, unsigned &CurByte,
590 int MemOperand, const MCInst &MI, 590 int MemOperand, const MCInst &MI,
591 const MCInstrDesc &Desc, 591 const MCInstrDesc &Desc,
592 raw_ostream &OS) const { 592 raw_ostream &OS) const {
593 assert(!(TSFlags & X86II::LOCK)); // Can't have LOCK VEX. @LOCALMOD
594
593 uint64_t Encoding = TSFlags & X86II::EncodingMask; 595 uint64_t Encoding = TSFlags & X86II::EncodingMask;
594 bool HasEVEX_K = TSFlags & X86II::EVEX_K; 596 bool HasEVEX_K = TSFlags & X86II::EVEX_K;
595 bool HasVEX_4V = TSFlags & X86II::VEX_4V; 597 bool HasVEX_4V = TSFlags & X86II::VEX_4V;
596 bool HasVEX_4VOp3 = TSFlags & X86II::VEX_4VOp3; 598 bool HasVEX_4VOp3 = TSFlags & X86II::VEX_4VOp3;
597 bool HasMemOp4 = TSFlags & X86II::MemOp4; 599 bool HasMemOp4 = TSFlags & X86II::MemOp4;
598 bool HasEVEX_RC = TSFlags & X86II::EVEX_RC; 600 bool HasEVEX_RC = TSFlags & X86II::EVEX_RC;
599 601
600 // VEX_R: opcode externsion equivalent to REX.R in 602 // VEX_R: opcode externsion equivalent to REX.R in
601 // 1's complement (inverted) form 603 // 1's complement (inverted) form
602 // 604 //
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 int MemOperand, const MCInst &MI, 1104 int MemOperand, const MCInst &MI,
1103 const MCInstrDesc &Desc, 1105 const MCInstrDesc &Desc,
1104 const MCSubtargetInfo &STI, 1106 const MCSubtargetInfo &STI,
1105 raw_ostream &OS) const { 1107 raw_ostream &OS) const {
1106 1108
1107 // Emit the operand size opcode prefix as needed. 1109 // Emit the operand size opcode prefix as needed.
1108 if ((TSFlags & X86II::OpSizeMask) == (is16BitMode(STI) ? X86II::OpSize32 1110 if ((TSFlags & X86II::OpSizeMask) == (is16BitMode(STI) ? X86II::OpSize32
1109 : X86II::OpSize16)) 1111 : X86II::OpSize16))
1110 EmitByte(0x66, CurByte, OS); 1112 EmitByte(0x66, CurByte, OS);
1111 1113
1114 // @LOCALMOD-START
1115 // Emit the LOCK opcode prefix.
1116 if (TSFlags & X86II::LOCK)
1117 EmitByte(0xF0, CurByte, OS);
1118 // @LOCALMOD-END
1119
1112 switch (TSFlags & X86II::OpPrefixMask) { 1120 switch (TSFlags & X86II::OpPrefixMask) {
1113 case X86II::PD: // 66 1121 case X86II::PD: // 66
1114 EmitByte(0x66, CurByte, OS); 1122 EmitByte(0x66, CurByte, OS);
1115 break; 1123 break;
1116 case X86II::XS: // F3 1124 case X86II::XS: // F3
1117 EmitByte(0xF3, CurByte, OS); 1125 EmitByte(0xF3, CurByte, OS);
1118 break; 1126 break;
1119 case X86II::XD: // F2 1127 case X86II::XD: // F2
1120 EmitByte(0xF2, CurByte, OS); 1128 EmitByte(0xF2, CurByte, OS);
1121 break; 1129 break;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 const unsigned MemOp4_I8IMMOperand = 2; 1183 const unsigned MemOp4_I8IMMOperand = 2;
1176 1184
1177 // It uses the EVEX.aaa field? 1185 // It uses the EVEX.aaa field?
1178 bool HasEVEX_K = TSFlags & X86II::EVEX_K; 1186 bool HasEVEX_K = TSFlags & X86II::EVEX_K;
1179 bool HasEVEX_RC = TSFlags & X86II::EVEX_RC; 1187 bool HasEVEX_RC = TSFlags & X86II::EVEX_RC;
1180 1188
1181 // Determine where the memory operand starts, if present. 1189 // Determine where the memory operand starts, if present.
1182 int MemoryOperand = X86II::getMemoryOperandNo(TSFlags, Opcode); 1190 int MemoryOperand = X86II::getMemoryOperandNo(TSFlags, Opcode);
1183 if (MemoryOperand != -1) MemoryOperand += CurOp; 1191 if (MemoryOperand != -1) MemoryOperand += CurOp;
1184 1192
1185 // Emit the lock opcode prefix as needed. 1193 // @LOCALMOD Moved LOCK prefix generation to EmitOpcodePrefix.
1186 if (TSFlags & X86II::LOCK)
1187 EmitByte(0xF0, CurByte, OS);
1188 1194
1189 // Emit segment override opcode prefix as needed. 1195 // Emit segment override opcode prefix as needed.
1190 if (MemoryOperand >= 0) 1196 if (MemoryOperand >= 0)
1191 EmitSegmentOverridePrefix(CurByte, MemoryOperand+X86::AddrSegmentReg, 1197 EmitSegmentOverridePrefix(CurByte, MemoryOperand+X86::AddrSegmentReg,
1192 MI, OS); 1198 MI, OS);
1193 1199
1194 // Emit the repeat opcode prefix as needed. 1200 // Emit the repeat opcode prefix as needed.
1195 if (TSFlags & X86II::REP) 1201 if (TSFlags & X86II::REP)
1196 EmitByte(0xF3, CurByte, OS); 1202 EmitByte(0xF3, CurByte, OS);
1197 1203
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 1238
1233 unsigned char BaseOpcode = X86II::getBaseOpcodeFor(TSFlags); 1239 unsigned char BaseOpcode = X86II::getBaseOpcodeFor(TSFlags);
1234 1240
1235 if (TSFlags & X86II::Has3DNow0F0FOpcode) 1241 if (TSFlags & X86II::Has3DNow0F0FOpcode)
1236 BaseOpcode = 0x0F; // Weird 3DNow! encoding. 1242 BaseOpcode = 0x0F; // Weird 3DNow! encoding.
1237 1243
1238 unsigned SrcRegNum = 0; 1244 unsigned SrcRegNum = 0;
1239 switch (TSFlags & X86II::FormMask) { 1245 switch (TSFlags & X86II::FormMask) {
1240 default: errs() << "FORM: " << (TSFlags & X86II::FormMask) << "\n"; 1246 default: errs() << "FORM: " << (TSFlags & X86II::FormMask) << "\n";
1241 llvm_unreachable("Unknown FormMask value in X86MCCodeEmitter!"); 1247 llvm_unreachable("Unknown FormMask value in X86MCCodeEmitter!");
1248 // @LOCALMOD-BEGIN
1249 case X86II::CustomFrm:
1250 llvm_unreachable("CustomFrm instruction shouldn't be emitted");
1251 // @LOCALMOD-END
1242 case X86II::Pseudo: 1252 case X86II::Pseudo:
1243 llvm_unreachable("Pseudo instruction shouldn't be emitted"); 1253 llvm_unreachable("Pseudo instruction shouldn't be emitted");
1244 case X86II::RawFrmDstSrc: { 1254 case X86II::RawFrmDstSrc: {
1245 unsigned siReg = MI.getOperand(1).getReg(); 1255 unsigned siReg = MI.getOperand(1).getReg();
1246 assert(((siReg == X86::SI && MI.getOperand(0).getReg() == X86::DI) || 1256 assert(((siReg == X86::SI && MI.getOperand(0).getReg() == X86::DI) ||
1247 (siReg == X86::ESI && MI.getOperand(0).getReg() == X86::EDI) || 1257 (siReg == X86::ESI && MI.getOperand(0).getReg() == X86::EDI) ||
1248 (siReg == X86::RSI && MI.getOperand(0).getReg() == X86::RDI)) && 1258 (siReg == X86::RSI && MI.getOperand(0).getReg() == X86::RDI)) &&
1249 "SI and DI register sizes do not match"); 1259 "SI and DI register sizes do not match");
1250 // Emit segment override opcode prefix as needed (not for %ds). 1260 // Emit segment override opcode prefix as needed (not for %ds).
1251 if (MI.getOperand(2).getReg() != X86::DS) 1261 if (MI.getOperand(2).getReg() != X86::DS)
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 #ifndef NDEBUG 1558 #ifndef NDEBUG
1549 // FIXME: Verify. 1559 // FIXME: Verify.
1550 if (/*!Desc.isVariadic() &&*/ CurOp != NumOps) { 1560 if (/*!Desc.isVariadic() &&*/ CurOp != NumOps) {
1551 errs() << "Cannot encode all operands of: "; 1561 errs() << "Cannot encode all operands of: ";
1552 MI.dump(); 1562 MI.dump();
1553 errs() << '\n'; 1563 errs() << '\n';
1554 abort(); 1564 abort();
1555 } 1565 }
1556 #endif 1566 #endif
1557 } 1567 }
OLDNEW
« no previous file with comments | « lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp ('k') | lib/Target/X86/MCTargetDesc/X86MCNaCl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698