summaryrefslogtreecommitdiff
path: root/lib/Target/X86/MCTargetDesc
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-01-06 06:02:58 +0000
committerCraig Topper <craig.topper@gmail.com>2014-01-06 06:02:58 +0000
commit30be10a06e1e6735a91826df63e1d0456cee7da2 (patch)
treea792453a9dbb864307c2500b2a59acb83e546e0f /lib/Target/X86/MCTargetDesc
parentb87d142ba189d404b7eb60a2f81d27836e093b06 (diff)
downloadllvm-30be10a06e1e6735a91826df63e1d0456cee7da2.tar.gz
llvm-30be10a06e1e6735a91826df63e1d0456cee7da2.tar.bz2
llvm-30be10a06e1e6735a91826df63e1d0456cee7da2.tar.xz
Add OpSize16 bit, for instructions which need 0x66 prefix in 16-bit mode
The 0x66 prefix toggles between 16-bit and 32-bit addressing mode. So in 32-bit mode it is used to switch to 16-bit addressing mode for the following instruction, while in 16-bit mode it's the other way round — it's used to switch to 32-bit mode instead. Thus, emit the 0x66 prefix byte for OpSize only in 32-bit (and 64-bit) mode, and introduce a new OpSize16 bit which is used in 16-bit mode instead. This is just the basic infrastructure for that change; a subsequent patch will add the new OpSize16 bit to the 32-bit instructions that need it. Patch from David Woodhouse. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198586 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/MCTargetDesc')
-rw-r--r--lib/Target/X86/MCTargetDesc/X86BaseInfo.h8
-rw-r--r--lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp3
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/Target/X86/MCTargetDesc/X86BaseInfo.h b/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
index 9c1ff15551..3de5d8255d 100644
--- a/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
+++ b/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
@@ -295,13 +295,15 @@ namespace X86II {
// OpSize - Set if this instruction requires an operand size prefix (0x66),
// which most often indicates that the instruction operates on 16 bit data
- // instead of 32 bit data.
+ // instead of 32 bit data. OpSize16 in 16 bit mode indicates that the
+ // instruction operates on 32 bit data instead of 16 bit data.
OpSize = 1 << 6,
+ OpSize16 = 1 << 7,
// AsSize - Set if this instruction requires an operand size prefix (0x67),
// which most often indicates that the instruction address 16 bit address
// instead of 32 bit address (or 32 bit address in 64 bit mode).
- AdSize = 1 << 7,
+ AdSize = 1 << 8,
//===------------------------------------------------------------------===//
// Op0Mask - There are several prefix bytes that are used to form two byte
@@ -309,7 +311,7 @@ namespace X86II {
// used to obtain the setting of this field. If no bits in this field is
// set, there is no prefix byte for obtaining a multibyte opcode.
//
- Op0Shift = 8,
+ Op0Shift = 9,
Op0Mask = 0x1F << Op0Shift,
// TB - TwoByte - Set if this instruction has a two byte opcode, which
diff --git a/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
index 51b90b1c49..06bce465b5 100644
--- a/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
+++ b/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
@@ -1191,8 +1191,7 @@ void X86MCCodeEmitter::EmitOpcodePrefix(uint64_t TSFlags, unsigned &CurByte,
EmitByte(0x67, CurByte, OS);
// Emit the operand size opcode prefix as needed.
- // FIXME for is16BitMode().
- if (TSFlags & X86II::OpSize)
+ if (TSFlags & (is16BitMode(Features) ? X86II::OpSize16 : X86II::OpSize))
EmitByte(0x66, CurByte, OS);
bool Need0FPrefix = false;