#BEGIN_LEGAL
#
#Copyright (c) 2020 Intel Corporation
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#  
#END_LEGAL

########  XOP #################################
SEQUENCE XOP_ENC_BIND
    XOP_TYPE_ENC_BIND
    VEX_REXR_ENC_BIND
    XOP_REXXB_ENC_BIND
    XOP_MAP_ENC_BIND
    VEX_REG_ENC_BIND
    VEX_ESCVL_ENC_BIND

SEQUENCE  XOP_ENC_EMIT
    XOP_TYPE_ENC_EMIT
    VEX_REXR_ENC_EMIT
    XOP_REXXB_ENC_EMIT
    XOP_MAP_ENC_EMIT
    VEX_REG_ENC_EMIT
    VEX_ESCVL_ENC_EMIT

##############################################

VEXED_REX()::
VEXVALID=3 -> XOP_ENC()

XOP_TYPE_ENC()::
XMAP8       -> 0x8F
XMAP9       -> 0x8F
XMAPA       -> 0x8F
otherwise   -> error

XOP_MAP_ENC()::
XMAP8  REXW[w] -> 0b0_1000 w
XMAP9  REXW[w] -> 0b0_1001 w
XMAPA  REXW[w] -> 0b0_1010 w
otherwise      -> error

XOP_REXXB_ENC()::
mode64  REXX=0 REXB=0  -> 0b11
mode64  REXX=1 REXB=0  -> 0b01
mode64  REXX=0 REXB=1  -> 0b10
mode64  REXX=1 REXB=1  -> 0b00
not64   REXX=0 REXB=0  -> 0b11
not64   REXX=1 REXB=0  -> error
not64   REXX=0 REXB=1  -> error
not64   REXX=1 REXB=1  -> error
otherwise              -> nothing
