Rename intel to x86.
x86 is the more accurate name, as there are non-Intel x86 implementations. Fixes #263.
This commit is contained in:
@@ -85,7 +85,7 @@ spiderwasm_prologue_words = NumSetting(
|
||||
|
||||
This setting configures the number of pointer-sized words pushed on the
|
||||
stack when the Cretonne-generated code is entered. This includes the
|
||||
pushed return address on Intel ISAs.
|
||||
pushed return address on x86.
|
||||
""")
|
||||
|
||||
#
|
||||
|
||||
@@ -7,7 +7,7 @@ architecture supported by Cretonne.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from cdsl.isa import TargetISA # noqa
|
||||
from . import riscv, intel, arm32, arm64
|
||||
from . import riscv, x86, arm32, arm64
|
||||
|
||||
try:
|
||||
from typing import List # noqa
|
||||
@@ -21,4 +21,4 @@ def all_isas():
|
||||
Get a list of all the supported target ISAs. Each target ISA is represented
|
||||
as a :py:class:`cretonne.TargetISA` instance.
|
||||
"""
|
||||
return [riscv.ISA, intel.ISA, arm32.ISA, arm64.ISA]
|
||||
return [riscv.ISA, x86.ISA, arm32.ISA, arm64.ISA]
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
"""
|
||||
Intel Target Architecture
|
||||
-------------------------
|
||||
|
||||
This target ISA generates code for Intel CPUs with two separate CPU modes:
|
||||
|
||||
`I32`
|
||||
IA-32 architecture, also known as 'x86'. Generates code for the Intel 386
|
||||
and later processors in 32-bit mode.
|
||||
`I64`
|
||||
Intel 64 architecture, also known as 'x86-64, 'x64', and 'amd64'. Intel and
|
||||
AMD CPUs running in 64-bit mode.
|
||||
|
||||
Floating point is supported only on CPUs with support for SSE2 or later. There
|
||||
is no x87 floating point support.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from . import defs
|
||||
from . import encodings, settings, registers # noqa
|
||||
|
||||
# Re-export the primary target ISA definition.
|
||||
ISA = defs.ISA.finish()
|
||||
21
lib/cretonne/meta/isa/x86/__init__.py
Normal file
21
lib/cretonne/meta/isa/x86/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
x86 Target Architecture
|
||||
-------------------------
|
||||
|
||||
This target ISA generates code for x86 CPUs with two separate CPU modes:
|
||||
|
||||
`I32`
|
||||
32-bit x86 architecture, also known as 'IA-32', also sometimes referred
|
||||
to as 'i386', however note that Cretonne depends on instructions not
|
||||
in the original `i386`, such as SSE2, CMOVcc, and UD2.
|
||||
|
||||
`I64`
|
||||
x86-64 architecture, also known as 'AMD64`, `Intel 64`, and 'x64'.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from . import defs
|
||||
from . import encodings, settings, registers # noqa
|
||||
|
||||
# Re-export the primary target ISA definition.
|
||||
ISA = defs.ISA.finish()
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Intel definitions.
|
||||
x86 definitions.
|
||||
|
||||
Commonly used definitions.
|
||||
"""
|
||||
@@ -9,7 +9,7 @@ import base.instructions
|
||||
from . import instructions as x86
|
||||
from base.immediates import floatcc
|
||||
|
||||
ISA = TargetISA('intel', [base.instructions.GROUP, x86.GROUP])
|
||||
ISA = TargetISA('x86', [base.instructions.GROUP, x86.GROUP])
|
||||
|
||||
# CPU modes for 32-bit and 64-bit operation.
|
||||
X86_64 = CPUMode('I64', ISA)
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Intel Encodings.
|
||||
x86 Encodings.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from cdsl.predicates import IsUnsignedInt, Not, And
|
||||
@@ -9,7 +9,7 @@ from .defs import X86_64, X86_32
|
||||
from . import recipes as r
|
||||
from . import settings as cfg
|
||||
from . import instructions as x86
|
||||
from .legalize import intel_expand
|
||||
from .legalize import x86_expand
|
||||
from base.legalize import narrow, expand_flags
|
||||
from base.settings import allones_funcaddrs, is_pic
|
||||
from .settings import use_sse41
|
||||
@@ -26,18 +26,18 @@ X86_32.legalize_monomorphic(expand_flags)
|
||||
X86_32.legalize_type(
|
||||
default=narrow,
|
||||
b1=expand_flags,
|
||||
i32=intel_expand,
|
||||
f32=intel_expand,
|
||||
f64=intel_expand)
|
||||
i32=x86_expand,
|
||||
f32=x86_expand,
|
||||
f64=x86_expand)
|
||||
|
||||
X86_64.legalize_monomorphic(expand_flags)
|
||||
X86_64.legalize_type(
|
||||
default=narrow,
|
||||
b1=expand_flags,
|
||||
i32=intel_expand,
|
||||
i64=intel_expand,
|
||||
f32=intel_expand,
|
||||
f64=intel_expand)
|
||||
i32=x86_expand,
|
||||
i64=x86_expand,
|
||||
f32=x86_expand,
|
||||
f64=x86_expand)
|
||||
|
||||
|
||||
#
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Supplementary instruction definitions for Intel.
|
||||
Supplementary instruction definitions for x86.
|
||||
|
||||
This module defines additional instructions that are useful only to the Intel
|
||||
This module defines additional instructions that are useful only to the x86
|
||||
target ISA.
|
||||
"""
|
||||
|
||||
@@ -11,7 +11,7 @@ from cdsl.typevar import TypeVar
|
||||
from cdsl.instructions import Instruction, InstructionGroup
|
||||
|
||||
|
||||
GROUP = InstructionGroup("x86", "Intel-specific instruction set")
|
||||
GROUP = InstructionGroup("x86", "x86-specific instruction set")
|
||||
|
||||
iWord = TypeVar('iWord', 'A scalar integer machine word', ints=(32, 64))
|
||||
|
||||
@@ -98,7 +98,7 @@ y = Operand('y', Float)
|
||||
|
||||
fmin = Instruction(
|
||||
'x86_fmin', r"""
|
||||
Floating point minimum with Intel semantics.
|
||||
Floating point minimum with x86 semantics.
|
||||
|
||||
This is equivalent to the C ternary operator `x < y ? x : y` which
|
||||
differs from :inst:`fmin` when either operand is NaN or when comparing
|
||||
@@ -111,7 +111,7 @@ fmin = Instruction(
|
||||
|
||||
fmax = Instruction(
|
||||
'x86_fmax', r"""
|
||||
Floating point maximum with Intel semantics.
|
||||
Floating point maximum with x86 semantics.
|
||||
|
||||
This is equivalent to the C ternary operator `x > y ? x : y` which
|
||||
differs from :inst:`fmax` when either operand is NaN or when comparing
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Custom legalization patterns for Intel.
|
||||
Custom legalization patterns for x86.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from cdsl.ast import Var
|
||||
@@ -10,12 +10,12 @@ from base import instructions as insts
|
||||
from . import instructions as x86
|
||||
from .defs import ISA
|
||||
|
||||
intel_expand = XFormGroup(
|
||||
'intel_expand',
|
||||
x86_expand = XFormGroup(
|
||||
'x86_expand',
|
||||
"""
|
||||
Legalize instructions by expansion.
|
||||
|
||||
Use Intel-specific instructions if needed.
|
||||
Use x86-specific instructions if needed.
|
||||
""",
|
||||
isa=ISA, chain=shared.expand_flags)
|
||||
|
||||
@@ -32,23 +32,23 @@ a2 = Var('a2')
|
||||
#
|
||||
# The srem expansion requires custom code because srem INT_MIN, -1 is not
|
||||
# allowed to trap. The other ops need to check avoid_div_traps.
|
||||
intel_expand.custom_legalize(insts.sdiv, 'expand_sdivrem')
|
||||
intel_expand.custom_legalize(insts.srem, 'expand_sdivrem')
|
||||
intel_expand.custom_legalize(insts.udiv, 'expand_udivrem')
|
||||
intel_expand.custom_legalize(insts.urem, 'expand_udivrem')
|
||||
x86_expand.custom_legalize(insts.sdiv, 'expand_sdivrem')
|
||||
x86_expand.custom_legalize(insts.srem, 'expand_sdivrem')
|
||||
x86_expand.custom_legalize(insts.udiv, 'expand_udivrem')
|
||||
x86_expand.custom_legalize(insts.urem, 'expand_udivrem')
|
||||
|
||||
#
|
||||
# Double length (widening) multiplication
|
||||
#
|
||||
resLo = Var('resLo')
|
||||
resHi = Var('resHi')
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
resHi << insts.umulhi(x, y),
|
||||
Rtl(
|
||||
(resLo, resHi) << x86.umulx(x, y)
|
||||
))
|
||||
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
resHi << insts.smulhi(x, y),
|
||||
Rtl(
|
||||
(resLo, resHi) << x86.smulx(x, y)
|
||||
@@ -61,14 +61,14 @@ intel_expand.legalize(
|
||||
# patterns.
|
||||
|
||||
# Equality needs an explicit `ord` test which checks the parity bit.
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
a << insts.fcmp(floatcc.eq, x, y),
|
||||
Rtl(
|
||||
a1 << insts.fcmp(floatcc.ord, x, y),
|
||||
a2 << insts.fcmp(floatcc.ueq, x, y),
|
||||
a << insts.band(a1, a2)
|
||||
))
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
a << insts.fcmp(floatcc.ne, x, y),
|
||||
Rtl(
|
||||
a1 << insts.fcmp(floatcc.uno, x, y),
|
||||
@@ -82,21 +82,21 @@ for cc, rev_cc in [
|
||||
(floatcc.le, floatcc.ge),
|
||||
(floatcc.ugt, floatcc.ult),
|
||||
(floatcc.uge, floatcc.ule)]:
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
a << insts.fcmp(cc, x, y),
|
||||
Rtl(
|
||||
a << insts.fcmp(rev_cc, y, x)
|
||||
))
|
||||
|
||||
# We need to modify the CFG for min/max legalization.
|
||||
intel_expand.custom_legalize(insts.fmin, 'expand_minmax')
|
||||
intel_expand.custom_legalize(insts.fmax, 'expand_minmax')
|
||||
x86_expand.custom_legalize(insts.fmin, 'expand_minmax')
|
||||
x86_expand.custom_legalize(insts.fmax, 'expand_minmax')
|
||||
|
||||
# Conversions from unsigned need special handling.
|
||||
intel_expand.custom_legalize(insts.fcvt_from_uint, 'expand_fcvt_from_uint')
|
||||
x86_expand.custom_legalize(insts.fcvt_from_uint, 'expand_fcvt_from_uint')
|
||||
# Conversions from float to int can trap.
|
||||
intel_expand.custom_legalize(insts.fcvt_to_sint, 'expand_fcvt_to_sint')
|
||||
intel_expand.custom_legalize(insts.fcvt_to_uint, 'expand_fcvt_to_uint')
|
||||
x86_expand.custom_legalize(insts.fcvt_to_sint, 'expand_fcvt_to_sint')
|
||||
x86_expand.custom_legalize(insts.fcvt_to_uint, 'expand_fcvt_to_uint')
|
||||
|
||||
# Count leading and trailing zeroes, for baseline x86_64
|
||||
c_minus_one = Var('c_minus_one')
|
||||
@@ -108,7 +108,7 @@ index1 = Var('index1')
|
||||
r2flags = Var('r2flags')
|
||||
index2 = Var('index2')
|
||||
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
a << insts.clz.i64(x),
|
||||
Rtl(
|
||||
c_minus_one << insts.iconst(imm64(-1)),
|
||||
@@ -118,7 +118,7 @@ intel_expand.legalize(
|
||||
a << insts.isub(c_sixty_three, index2),
|
||||
))
|
||||
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
a << insts.clz.i32(x),
|
||||
Rtl(
|
||||
c_minus_one << insts.iconst(imm64(-1)),
|
||||
@@ -128,7 +128,7 @@ intel_expand.legalize(
|
||||
a << insts.isub(c_thirty_one, index2),
|
||||
))
|
||||
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
a << insts.ctz.i64(x),
|
||||
Rtl(
|
||||
c_sixty_four << insts.iconst(imm64(64)),
|
||||
@@ -136,7 +136,7 @@ intel_expand.legalize(
|
||||
a << insts.selectif(intcc.eq, r2flags, c_sixty_four, index1),
|
||||
))
|
||||
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
a << insts.ctz.i32(x),
|
||||
Rtl(
|
||||
c_thirty_two << insts.iconst(imm64(32)),
|
||||
@@ -164,7 +164,7 @@ qv16 = Var('qv16')
|
||||
qc77 = Var('qc77')
|
||||
qc0F = Var('qc0F')
|
||||
qc01 = Var('qc01')
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
qv16 << insts.popcnt.i64(qv1),
|
||||
Rtl(
|
||||
qv3 << insts.ushr_imm(qv1, imm64(1)),
|
||||
@@ -204,7 +204,7 @@ lv16 = Var('lv16')
|
||||
lc77 = Var('lc77')
|
||||
lc0F = Var('lc0F')
|
||||
lc01 = Var('lc01')
|
||||
intel_expand.legalize(
|
||||
x86_expand.legalize(
|
||||
lv16 << insts.popcnt.i32(lv1),
|
||||
Rtl(
|
||||
lv3 << insts.ushr_imm(lv1, imm64(1)),
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Intel Encoding recipes.
|
||||
x86 Encoding recipes.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from cdsl.isa import EncRecipe
|
||||
@@ -31,7 +31,7 @@ except ImportError:
|
||||
# Opcode representation.
|
||||
#
|
||||
# Cretonne requires each recipe to have a single encoding size in bytes, and
|
||||
# Intel opcodes are variable length, so we use separate recipes for different
|
||||
# x86 opcodes are variable length, so we use separate recipes for different
|
||||
# styles of opcodes and prefixes. The opcode format is indicated by the recipe
|
||||
# name prefix:
|
||||
|
||||
@@ -124,7 +124,7 @@ class TailRecipe:
|
||||
"""
|
||||
Generate encoding recipes on demand.
|
||||
|
||||
Intel encodings are somewhat orthogonal with the opcode representation on
|
||||
x86 encodings are somewhat orthogonal with the opcode representation on
|
||||
one side and the ModR/M, SIB and immediate fields on the other side.
|
||||
|
||||
A `TailRecipe` represents the part of an encoding that follow the opcode.
|
||||
@@ -144,7 +144,7 @@ class TailRecipe:
|
||||
|
||||
The `emit` parameter contains Rust code to actually emit an encoding, like
|
||||
`EncRecipe` does it. Additionally, the text `PUT_OP` is substituted with
|
||||
the proper `put_*` function from the `intel/binemit.rs` module.
|
||||
the proper `put_*` function from the `x86/binemit.rs` module.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -590,7 +590,7 @@ fnaddr4 = TailRecipe(
|
||||
'fnaddr4', FuncAddr, size=4, ins=(), outs=GPR,
|
||||
emit='''
|
||||
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::IntelAbs4,
|
||||
sink.reloc_external(Reloc::X86Abs4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
sink.put4(0);
|
||||
@@ -601,7 +601,7 @@ fnaddr8 = TailRecipe(
|
||||
'fnaddr8', FuncAddr, size=8, ins=(), outs=GPR,
|
||||
emit='''
|
||||
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::IntelAbs8,
|
||||
sink.reloc_external(Reloc::X86Abs8,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
sink.put8(0);
|
||||
@@ -612,7 +612,7 @@ allones_fnaddr4 = TailRecipe(
|
||||
'allones_fnaddr4', FuncAddr, size=4, ins=(), outs=GPR,
|
||||
emit='''
|
||||
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::IntelAbs4,
|
||||
sink.reloc_external(Reloc::X86Abs4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
// Write the immediate as `!0` for the benefit of BaldrMonkey.
|
||||
@@ -624,7 +624,7 @@ allones_fnaddr8 = TailRecipe(
|
||||
'allones_fnaddr8', FuncAddr, size=8, ins=(), outs=GPR,
|
||||
emit='''
|
||||
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::IntelAbs8,
|
||||
sink.reloc_external(Reloc::X86Abs8,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
0);
|
||||
// Write the immediate as `!0` for the benefit of BaldrMonkey.
|
||||
@@ -640,7 +640,7 @@ got_fnaddr8 = TailRecipe(
|
||||
modrm_riprel(out_reg0, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::IntelGOTPCRel4,
|
||||
sink.reloc_external(Reloc::X86GOTPCRel4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -652,7 +652,7 @@ gvaddr4 = TailRecipe(
|
||||
'gvaddr4', UnaryGlobalVar, size=4, ins=(), outs=GPR,
|
||||
emit='''
|
||||
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::IntelAbs4,
|
||||
sink.reloc_external(Reloc::X86Abs4,
|
||||
&func.global_vars[global_var].symbol_name(),
|
||||
0);
|
||||
sink.put4(0);
|
||||
@@ -663,7 +663,7 @@ gvaddr8 = TailRecipe(
|
||||
'gvaddr8', UnaryGlobalVar, size=8, ins=(), outs=GPR,
|
||||
emit='''
|
||||
PUT_OP(bits | (out_reg0 & 7), rex1(out_reg0), sink);
|
||||
sink.reloc_external(Reloc::IntelAbs8,
|
||||
sink.reloc_external(Reloc::X86Abs8,
|
||||
&func.global_vars[global_var].symbol_name(),
|
||||
0);
|
||||
sink.put8(0);
|
||||
@@ -677,7 +677,7 @@ got_gvaddr8 = TailRecipe(
|
||||
modrm_rm(5, out_reg0, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::IntelGOTPCRel4,
|
||||
sink.reloc_external(Reloc::X86GOTPCRel4,
|
||||
&func.global_vars[global_var].symbol_name(),
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -1009,7 +1009,7 @@ call_id = TailRecipe(
|
||||
PUT_OP(bits, BASE_REX, sink);
|
||||
// The addend adjusts for the difference between the end of the
|
||||
// instruction and the beginning of the immediate field.
|
||||
sink.reloc_external(Reloc::IntelPCRel4,
|
||||
sink.reloc_external(Reloc::X86PCRel4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -1019,7 +1019,7 @@ call_plt_id = TailRecipe(
|
||||
'call_plt_id', Call, size=4, ins=(), outs=(),
|
||||
emit='''
|
||||
PUT_OP(bits, BASE_REX, sink);
|
||||
sink.reloc_external(Reloc::IntelPLTRel4,
|
||||
sink.reloc_external(Reloc::X86PLTRel4,
|
||||
&func.dfg.ext_funcs[func_ref].name,
|
||||
-4);
|
||||
sink.put4(0);
|
||||
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
Intel register banks.
|
||||
x86 register banks.
|
||||
|
||||
While the floating-point registers are straight-forward, the general purpose
|
||||
register bank has a few quirks on Intel architectures. We have these encodings
|
||||
of the 8-bit registers:
|
||||
register bank has a few quirks on x86. We have these encodings of the 8-bit
|
||||
registers:
|
||||
|
||||
I32 I64 | 16b 32b 64b
|
||||
000 AL AL | AX EAX RAX
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Intel settings.
|
||||
x86 settings.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from cdsl.settings import SettingGroup, BoolSetting, Preset
|
||||
@@ -7,7 +7,7 @@ from cdsl.predicates import And
|
||||
import base.settings as shared
|
||||
from .defs import ISA
|
||||
|
||||
ISA.settings = SettingGroup('intel', parent=shared.group)
|
||||
ISA.settings = SettingGroup('x86', parent=shared.group)
|
||||
|
||||
# The has_* settings here correspond to CPUID bits.
|
||||
|
||||
@@ -35,7 +35,7 @@ use_popcnt = And(has_popcnt, has_sse42)
|
||||
use_bmi1 = And(has_bmi1)
|
||||
use_lzcnt = And(has_lzcnt)
|
||||
|
||||
# Presets corresponding to Intel CPUs.
|
||||
# Presets corresponding to x86 CPUs.
|
||||
|
||||
baseline = Preset()
|
||||
nehalem = Preset(
|
||||
Reference in New Issue
Block a user