Skip to content

Commit

Permalink
Add ability to override segment (mostly for code emitter purposes).
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57380 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
asl committed Oct 11, 2008
1 parent b7dfaf9 commit ef93cec
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Target/X86/X86.td
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def X86InstrInfo : InstrInfo {
"ImmTypeBits",
"FPFormBits",
"hasLockPrefix",
"SegOvrBits",
"Opcode"];
let TSFlagsShifts = [0,
6,
Expand All @@ -125,6 +126,7 @@ def X86InstrInfo : InstrInfo {
13,
16,
19,
20,
24];
}

Expand Down
10 changes: 10 additions & 0 deletions lib/Target/X86/X86CodeEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,16 @@ void Emitter::emitInstruction(const MachineInstr &MI,
// Emit the lock opcode prefix as needed.
if (Desc->TSFlags & X86II::LOCK) MCE.emitByte(0xF0);

// Emit segment overrid opcode prefix as needed.
switch (Desc->TSFlags & X86II::SegOvrMask) {
case X86II::FS:
MCE.emitByte(0x64);
break;
case X86II::GS:
MCE.emitByte(0x65);
break;
}

// Emit the repeat opcode prefix as needed.
if ((Desc->TSFlags & X86II::Op0Mask) == X86II::REP) MCE.emitByte(0xF3);

Expand Down
3 changes: 3 additions & 0 deletions lib/Target/X86/X86InstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class OpSize { bit hasOpSizePrefix = 1; }
class AdSize { bit hasAdSizePrefix = 1; }
class REX_W { bit hasREX_WPrefix = 1; }
class LOCK { bit hasLockPrefix = 1; }
class SegFS { bits<2> SegOvrBits = 1; }
class SegGS { bits<2> SegOvrBits = 2; }
class TB { bits<4> Prefix = 1; }
class REP { bits<4> Prefix = 2; }
class D8 { bits<4> Prefix = 3; }
Expand Down Expand Up @@ -104,6 +106,7 @@ class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
FPFormat FPForm; // What flavor of FP instruction is this?
bits<3> FPFormBits = 0;
bit hasLockPrefix = 0; // Does this inst have a 0xF0 prefix?
bits<2> SegOvrBits = 0; // Segment override prefix.
}

class I<bits<8> o, Format f, dag outs, dag ins, string asm, list<dag> pattern>
Expand Down
9 changes: 8 additions & 1 deletion lib/Target/X86/X86InstrInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ namespace X86II {
LOCKShift = 19,
LOCK = 1 << LOCKShift,

// Bits 20 -> 23 are unused
// Segment override prefixes. Currently we just need ability to address
// stuff in gs and fs segments.
SegOvrShift = 20,
SegOvrMask = 3 << SegOvrShift,
FS = 1 << SegOvrShift,
GS = 2 << SegOvrShift,

// Bits 22 -> 23 are unused
OpcodeShift = 24,
OpcodeMask = 0xFF << OpcodeShift
};
Expand Down

0 comments on commit ef93cec

Please sign in to comment.