...
 
Commits (63)
......@@ -43,6 +43,11 @@ test:cargo:runtime:
script:
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 ./test-release --color=always test_runtime 2> /dev/null
test:cargo:jit:
stage: test
script:
- RUST_BACKTRACE=1 RUST_TEST_THREADS=1 ./test-release --color=always test_jit_rust 2> /dev/null
.build_muc: &build_muc |
if [ -d "tests/test_muc/mu-tool-compiler" ]; then rm -Rf tests/test_muc/mu-tool-compiler; fi
cd tests/test_muc
......
......@@ -23,9 +23,9 @@ crate-type = ["staticlib", "rlib", "dylib"]
doctest = false
[features]
default = ["aot"]
aot = []
jit = []
default = ["binary-codegen", "asm-codegen"]
asm-codegen = []
binary-codegen = []
sel4-rumprun = []
sel4-rumprun-target-side = []
......@@ -33,6 +33,9 @@ sel4-rumprun-target-side = []
gcc = "*"
#built = "0.1"
[target.'cfg(target_arch = "x86_64")'.dependencies]
xed_bindings = {path = "src/compiler/backend/arch/x86_64/binary_backend/xed_bindings"}
[dependencies]
mu_ast = {path = "src/ast"}
mu_utils = {path = "src/utils"}
......@@ -58,6 +61,7 @@ docopt = "*"
petgraph = "*"
extprim = "*"
num-traits = "*"
nix = "*"
#built = "0.1"
[target.aarch64-unknown-linux-gnu.dependencies]
......
......@@ -14,7 +14,6 @@
#[cfg(not(feature = "sel4-rumprun-target-side"))]
extern crate built;
extern crate gcc;
#[cfg(not(feature = "sel4-rumprun-target-side"))]
......@@ -24,13 +23,14 @@ fn main() {
gcc::Build::new()
.flag("-O3")
.flag("-c")
.file("src/runtime/runtime_c_x64_sysv.c")
.file("src/runtime/native_helpers/runtime_c_x64_sysv.c")
.file("src/runtime/native_helpers/runtime_c_sysv.c")
.compile("libruntime_c.a");
gcc::Build::new()
.flag("-O3")
.flag("-c")
.file("src/runtime/runtime_asm_x64_sysv.S")
.file("src/runtime/native_helpers/runtime_asm_x64_sysv.S")
.compile("libruntime_asm.a");
built();
......@@ -43,13 +43,13 @@ fn main() {
gcc::Build::new()
.flag("-O3")
.flag("-c")
.file("src/runtime/runtime_c_aarch64_sysv.c")
.file("src/runtime/native_helpers/runtime_c_sysv.c")
.compile("libruntime_c.a");
gcc::Build::new()
.flag("-O3")
.flag("-c")
.file("src/runtime/runtime_asm_aarch64_sysv.S")
.file("src/runtime/native_helpers/runtime_asm_aarch64_sysv.S")
.compile("libruntime_asm.a");
built();
......
......@@ -31,6 +31,8 @@ pub struct Instruction {
/// and in Instruction_, the children nodes are referred by indices
/// This design makes it easy for the compiler to iterate through all the children
pub ops: Vec<P<TreeNode>>,
/// values that need to be kept alive at this instruction
pub keepalives: Option<Vec<P<Value>>>,
/// used for pattern matching
pub v: Instruction_
}
......@@ -44,6 +46,7 @@ impl Clone for Instruction {
hdr: self.hdr.clone(),
value: self.value.clone(),
ops: self.ops.clone(),
keepalives: self.keepalives.clone(),
v: self.v.clone()
}
}
......@@ -818,7 +821,7 @@ impl Instruction_ {
resume.debug_str(ops)
)
}
None => format!("TRAP {}", resume.debug_str(ops))
None => format!("WP/TRAP {}", resume.debug_str(ops))
}
}
&Instruction_::WPBranch {
......
......@@ -24,13 +24,17 @@ use std;
use std::fmt;
pub use std::sync::Arc;
use std::default;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
pub type WPID = usize;
pub type MuID = usize;
pub type MuName = Arc<String>;
pub type CName = MuName;
lazy_static!{
pub static ref EMPTY_MU_NAME: MuName = Arc::new(String::new());
}
#[allow(non_snake_case)]
pub fn Mu(str: &'static str) -> MuName {
Arc::new(str.to_string())
......@@ -76,6 +80,14 @@ pub fn new_machine_id() -> MuID {
ret
}
pub fn is_machine_id(id: MuID) -> bool {
if id >= MACHINE_ID_START && id <= MACHINE_ID_END {
true
} else {
false
}
}
pub fn new_internal_id() -> MuID {
let ret = INTERNAL_ID.fetch_add(1, Ordering::SeqCst);
if ret >= INTERNAL_ID_END {
......@@ -152,23 +164,31 @@ pub struct MuFunctionVersion {
rodal_struct!(Callsite {
name,
exception_destination,
stack_arg_size
stack_arg_size,
callee,
keepalives
});
pub struct Callsite {
pub name: MuName,
pub exception_destination: Option<MuName>,
pub stack_arg_size: usize
pub stack_arg_size: usize,
pub callee: MuID,
pub keepalives: Option<Vec<MuID>>
}
impl Callsite {
pub fn new(
name: MuName,
exception_destination: Option<MuName>,
stack_arg_size: usize
stack_arg_size: usize,
callee: MuID,
keepalives: Option<Vec<MuID>>
) -> Callsite {
Callsite {
name: name,
exception_destination: exception_destination,
stack_arg_size: stack_arg_size
stack_arg_size: stack_arg_size,
callee: callee,
keepalives: keepalives
}
}
}
......@@ -713,8 +733,7 @@ pub enum EdgeKind {
pub struct BlockContent {
pub args: Vec<P<Value>>,
pub exn_arg: Option<P<Value>>,
pub body: Vec<Box<TreeNode>>,
pub keepalives: Option<Vec<P<Value>>>
pub body: Vec<Box<TreeNode>>
}
impl fmt::Debug for BlockContent {
......@@ -723,13 +742,6 @@ impl fmt::Debug for BlockContent {
if self.exn_arg.is_some() {
writeln!(f, "exception arg: {}", self.exn_arg.as_ref().unwrap()).unwrap();
}
if self.keepalives.is_some() {
writeln!(
f,
"keepalives: {}",
vec_utils::as_str(self.keepalives.as_ref().unwrap())
).unwrap();
}
for node in self.body.iter() {
writeln!(f, "{}", node).unwrap();
}
......@@ -830,8 +842,7 @@ impl BlockContent {
BlockContent {
args: self.args.clone(),
exn_arg: self.exn_arg.clone(),
body: vec![],
keepalives: self.keepalives.clone()
body: vec![]
}
}
}
......
......@@ -93,7 +93,6 @@ lazy_static! {
UINT128_TYPE.clone(),
FLOAT_TYPE.clone(),
DOUBLE_TYPE.clone(),
FLOAT_TYPE.clone(),
VOID_TYPE.clone(),
REF_VOID_TYPE.clone(),
IREF_VOID_TYPE.clone(),
......
......@@ -19,7 +19,7 @@ use utils::Address;
use utils::POINTER_SIZE;
use compiler::backend::aarch64::*;
use compiler::backend::{Reg, Mem};
use compiler::backend::{Mem, Reg};
use compiler::machine_code::MachineCode;
use vm::VM;
use runtime::ValueLocation;
......@@ -514,6 +514,21 @@ impl ASMCode {
fn add_frame_size_patchpoint(&mut self, patchpoint: ASMLocation) {
self.frame_size_patchpoints.push(patchpoint);
}
fn emit(&self) -> Vec<u8> {
let mut ret = vec![];
for inst in self.code.iter() {
if !inst.is_symbol {
ret.append(&mut "\t".to_string().into_bytes());
}
ret.append(&mut inst.code.clone().into_bytes());
ret.append(&mut "\n".to_string().into_bytes());
}
ret
}
}
use std::any::Any;
......@@ -522,6 +537,9 @@ impl MachineCode for ASMCode {
fn as_any(&self) -> &Any {
self
}
fn as_any_mut(&mut self) -> &mut Any {
self
}
fn number_of_insts(&self) -> usize {
self.code.len()
}
......@@ -770,31 +788,16 @@ impl MachineCode for ASMCode {
}
}
fn emit(&self) -> Vec<u8> {
let mut ret = vec![];
for inst in self.code.iter() {
if !inst.is_symbol {
ret.append(&mut "\t".to_string().into_bytes());
}
ret.append(&mut inst.code.clone().into_bytes());
ret.append(&mut "\n".to_string().into_bytes());
}
ret
}
fn emit_inst(&self, index: usize) -> Vec<u8> {
let mut ret = vec![];
fn get_inst_text(&self, index: usize) -> String {
let mut ret = String::new();
let ref inst = self.code[index];
if !inst.is_symbol {
ret.append(&mut "\t".to_string().into_bytes());
ret.push('\t');
}
ret.append(&mut inst.code.clone().into_bytes());
ret.push_str(&inst.code);
ret
}
......@@ -3427,7 +3430,8 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
}
// write code
let code = cf.mc.as_ref().unwrap().emit();
let asmcode: &ASMCode = cf.mc.as_ref().unwrap().as_any().downcast_ref().unwrap();
let code = asmcode.emit();
match file.write_all(code.as_slice()) {
Err(why) => {
panic!(
......
#![allow(unused_variables)]
use ast::ir::*;
use ast::ptr::P;
use vm::VM;
use utils::Address;
use utils::ByteSize;
use utils::LinkedHashMap;
use compiler::machine_code::CompiledFunction;
use std::collections::HashMap;
pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
unimplemented!()
}
pub fn emit_context(vm: &VM) {
emit_context_with_reloc(vm, hashmap!{}, hashmap!{});
}
/// emit vm context for current session, considering relocation symbols/fields from the client
pub fn emit_context_with_reloc(
vm: &VM,
symbols: HashMap<Address, String>,
fields: HashMap<Address, String>
) {
unimplemented!()
}
pub fn spill_rewrite(
spills: &LinkedHashMap<MuID, P<Value>>,
func: &mut MuFunctionVersion,
cf: &mut CompiledFunction,
vm: &VM
) -> LinkedHashMap<MuID, MuID> {
unimplemented!()
}
pub fn jit_patch_call_addr(dest: Address, inst_start: Address, length: ByteSize) {
unimplemented!()
}
pub fn jit_patch_jmp_addr(dest: Address, inst_start: Address, length: ByteSize) {
unimplemented!()
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ use ast::ptr::P;
use runtime::ValueLocation;
use compiler::machine_code::MachineCode;
use compiler::backend::{Reg, Mem};
use compiler::backend::{Mem, Reg};
pub trait CodeGenerator {
fn start_code(&mut self, func_name: MuName, entry: MuName) -> ValueLocation;
......
......@@ -13,13 +13,11 @@
// limitations under the License.
#![allow(dead_code)]
// TODO: CHECK THAT THE TYPE OF EVERY MEMORY LOCATION HAS THE CORRECT SIZE
// (the size should be size of the area in memory that it is referring to, and will indicate
// how much data any load/store instructions that uses it will operate on
// (so it should be [1], 8, 16, 32, 64, or 128 bits in size (when using emit_mem,
// it can have other sizes before this))
#![allow(non_upper_case_globals)]
// TODO: Move architecture independent codes in here, inst_sel and asm_backend to somewhere else...
pub mod inst_sel;
......@@ -29,16 +27,13 @@ use utils::bit_utils::bits_ones;
mod codegen;
pub use compiler::backend::aarch64::codegen::CodeGenerator;
mod asm_backend;
pub use compiler::backend::aarch64::asm_backend::ASMCodeGen;
pub use compiler::backend::aarch64::asm_backend::emit_code;
pub use compiler::backend::aarch64::asm_backend::emit_context;
pub use compiler::backend::aarch64::asm_backend::emit_context_with_reloc;
use utils::Address;
#[cfg(feature = "asm-codegen")]
pub mod asm_backend;
#[cfg(feature = "aot")]
pub use compiler::backend::aarch64::asm_backend::spill_rewrite;
#[cfg(feature = "binary-codegen")]
pub mod binary_backend;
use utils::Address;
use ast::ptr::P;
use ast::ir::*;
use ast::types::*;
......
......@@ -21,7 +21,7 @@ use utils::Address;
use utils::POINTER_SIZE;
use compiler::backend::x86_64;
use compiler::backend::x86_64::CodeGenerator;
use compiler::backend::{Reg, Mem};
use compiler::backend::{Mem, Reg};
use compiler::backend::x86_64::check_op_len;
use compiler::machine_code::MachineCode;
use vm::VM;
......@@ -625,6 +625,22 @@ impl ASMCode {
fn add_frame_size_patchpoint(&mut self, patchpoint: ASMLocation) {
self.frame_size_patchpoints.push(patchpoint);
}
/// emit the machine code as a byte array
fn emit(&self) -> Vec<u8> {
let mut ret = vec![];
for inst in self.code.iter() {
if !inst.is_symbol {
ret.append(&mut "\t".to_string().into_bytes());
}
ret.append(&mut inst.code.clone().into_bytes());
ret.append(&mut "\n".to_string().into_bytes());
}
ret
}
}
impl MachineCode for ASMCode {
......@@ -632,6 +648,10 @@ impl MachineCode for ASMCode {
self
}
fn as_any_mut(&mut self) -> &mut Any {
self
}
/// returns the count of instructions in this machine code
fn number_of_insts(&self) -> usize {
self.code.len()
......@@ -912,33 +932,17 @@ impl MachineCode for ASMCode {
}
}
/// emit the machine code as a byte array
fn emit(&self) -> Vec<u8> {
let mut ret = vec![];
for inst in self.code.iter() {
if !inst.is_symbol {
ret.append(&mut "\t".to_string().into_bytes());
}
ret.append(&mut inst.code.clone().into_bytes());
ret.append(&mut "\n".to_string().into_bytes());
}
ret
}
/// emit the machine instruction at the given index as a byte array
fn emit_inst(&self, index: usize) -> Vec<u8> {
let mut ret = vec![];
fn get_inst_text(&self, index: usize) -> String {
let mut ret = String::new();
let ref inst = self.code[index];
if !inst.is_symbol {
ret.append(&mut "\t".to_string().into_bytes());
ret.push('\t');
}
ret.append(&mut inst.code.clone().into_bytes());
ret.push_str(&inst.code);
ret
}
......@@ -2479,6 +2483,28 @@ impl CodeGenerator for ASMCodeGen {
self.add_asm_inst(asm, linked_hashmap!{}, linked_hashmap!{}, false);
}
fn register_fence(&mut self, uses: Vec<P<Value>>, defs: Vec<P<Value>>) {
trace!("emit: register fence");
let asm = String::from("nop");
let defs = {
let mut ret = LinkedHashMap::new();
for r in defs {
ret.insert(r.id(), vec![]);
}
ret
};
let uses = {
let mut ret = LinkedHashMap::new();
for r in uses {
ret.insert(r.id(), vec![]);
}
ret
};
self.add_asm_inst(asm, defs, uses, false);
}
// cmp
fn emit_cmp_r_r(&mut self, op1: &P<Value>, op2: &P<Value>) {
......@@ -3206,6 +3232,16 @@ impl CodeGenerator for ASMCodeGen {
self.add_asm_branch(asm, dest_name)
}
fn emit_wpbranch_jmp(
&mut self,
wpid: MuID,
target: MuName,
disable_target: MuName,
enable_target: MuName
) {
panic!("cannot emit wpbranch_jmp with asm backend (requires runtime code patching)")
}
fn emit_je(&mut self, dest_name: MuName) {
trace!("emit: je {}", dest_name);
......@@ -3283,10 +3319,13 @@ impl CodeGenerator for ASMCodeGen {
self.add_asm_branch2(asm, dest_name);
}
#[allow(unused_variables)]
fn emit_call_near_rel32(
&mut self,
callsite: MuName,
func: MuName,
func_id: MuID,
addr: Address,
pe: Option<MuName>,
uses: Vec<P<Value>>,
defs: Vec<P<Value>>,
......@@ -3757,7 +3796,8 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
}
// write code
let code = cf.mc.as_ref().unwrap().emit();
let asmcode: &ASMCode = cf.mc.as_ref().unwrap().as_any().downcast_ref().unwrap();
let code = asmcode.emit();
match file.write_all(code.as_slice()) {
Err(why) => {
panic!(
......
// in development
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use ast::ir::*;
use ast::ptr::P;
use ast::types;
use vm::VM;
use utils::Address;
use utils::LinkedHashMap;
use compiler::machine_code::CompiledFunction;
use std::collections::HashMap;
extern crate xed_bindings as xed;
mod binary_codegen;
pub use self::binary_codegen::BinaryCodeGen;
pub use self::binary_codegen::init_jit;
pub use self::binary_codegen::emit_code;
pub use self::binary_codegen::jit_patch_call_addr;
pub use self::binary_codegen::jit_patch_jmp_addr;
mod code_context;
pub fn emit_context(vm: &VM) {
emit_context_with_reloc(vm, hashmap!{}, hashmap!{});
}
/// emit vm context for current session, considering relocation symbols/fields from the client
pub fn emit_context_with_reloc(
vm: &VM,
symbols: HashMap<Address, String>,
fields: HashMap<Address, String>
) {
unimplemented!()
}
pub fn spill_rewrite(
spills: &LinkedHashMap<MuID, P<Value>>,
func: &mut MuFunctionVersion,
cf: &mut CompiledFunction,
vm: &VM
) -> LinkedHashMap<MuID, MuID> {
unimplemented!()
}
[package]
name = "xed_bindings"
version = "0.1.0"
authors = ["qinsoon <qinsoon@gmail.com>"]
build = "build.rs"
[dependencies]
log = "*"
stderrlog = "*"
\ No newline at end of file
#[cfg(target_arch = "x86_64")]
fn main() {
use std::path;
// compute lib directory from current file (otherwise when building from zebu_root/,
// cargo may try find xed in zebu_root/lib
let lib_dir = {
let cur_file = file!();
let xed_binding_root_dir = path::Path::new(cur_file).parent().unwrap();
let mut ret = path::PathBuf::from(xed_binding_root_dir);
ret.push("lib");
ret
};
let lib_name = if cfg!(target_os = "macos") {
"xed_macos"
} else if cfg!(target_os = "linux") {
"xed_linux"
} else {
panic!("unsupported os, require a static library libxed for the target")
};
println!("cargo:rustc-link-lib=static={}", lib_name);
println!(
"cargo:rustc-link-search=native={}",
lib_dir.to_str().unwrap()
);
}
#[cfg(not(target_arch = "x86_64"))]
fn main() {
panic!("xed should not be built on other platform other than x86_64");
}
/// @file xed-address-width-enum.h
// This file was automatically generated.
// Do not edit this file.
#if !defined(XED_ADDRESS_WIDTH_ENUM_H)
# define XED_ADDRESS_WIDTH_ENUM_H
#include "xed-common-hdrs.h"
typedef enum {
XED_ADDRESS_WIDTH_INVALID=0,
XED_ADDRESS_WIDTH_16b=2, ///< 16b addressing
XED_ADDRESS_WIDTH_32b=4, ///< 32b addressing
XED_ADDRESS_WIDTH_64b=8, ///< 64b addressing
XED_ADDRESS_WIDTH_LAST
} xed_address_width_enum_t;
/// This converts strings to #xed_address_width_enum_t types.
/// @param s A C-string.
/// @return #xed_address_width_enum_t
/// @ingroup ENUM
XED_DLL_EXPORT xed_address_width_enum_t str2xed_address_width_enum_t(const char* s);
/// This converts strings to #xed_address_width_enum_t types.
/// @param p An enumeration element of type xed_address_width_enum_t.
/// @return string
/// @ingroup ENUM
XED_DLL_EXPORT const char* xed_address_width_enum_t2str(const xed_address_width_enum_t p);
/// Returns the last element of the enumeration
/// @return xed_address_width_enum_t The last element of the enumeration.
/// @ingroup ENUM
XED_DLL_EXPORT xed_address_width_enum_t xed_address_width_enum_t_last(void);
#endif
/*BEGIN_LEGAL
Copyright (c) 2016 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 */
/// @file xed-agen.h
///
#ifndef XED_AGEN_H
# define XED_AGEN_H
#include "xed-decoded-inst.h"
#include "xed-error-enum.h"
/// A function for obtaining register values. 32b return values should be
/// zero extended to 64b. The error value is set to nonzero if the callback
/// experiences some sort of problem. @ingroup AGEN
typedef xed_uint64_t (*xed_register_callback_fn_t)(xed_reg_enum_t reg,
void* context,
xed_bool_t* error);
/// A function for obtaining the segment base values. 32b return values
/// should be zero extended zero extended to 64b. The error value is set to
/// nonzero if the callback experiences some sort of problem.
/// @ingroup AGEN
typedef xed_uint64_t (*xed_segment_base_callback_fn_t)(xed_reg_enum_t reg,
void* context,
xed_bool_t* error);
/// Initialize the callback functions. Tell XED what to call when using
/// #xed_agen.
/// @ingroup AGEN
XED_DLL_EXPORT void xed_agen_register_callback(xed_register_callback_fn_t register_fn,
xed_segment_base_callback_fn_t segment_fn);
/// Using the registered callbacks, compute the memory address for a
/// specified memop in a decoded instruction. memop_index can have the
/// value 0 for XED_OPERAND_MEM0, XED_OPERAND_AGEN, or 1 for
/// XED_OPERAND_MEM1. Any other value results in an error being
/// returned. The context parameter which is passed to the registered
/// callbacks can be used to identify which thread's state is being
/// referenced. The context parameter can also be used to specify which
/// element of a vector register should be returned for gather an scatter
/// operations.
/// @ingroup AGEN
XED_DLL_EXPORT xed_error_enum_t xed_agen(xed_decoded_inst_t* xedd,
unsigned int memop_index,
void* context,
xed_uint64_t* out_address);
#endif
/// @file xed-attribute-enum.h
// This file was automatically generated.
// Do not edit this file.
#if !defined(XED_ATTRIBUTE_ENUM_H)
# define XED_ATTRIBUTE_ENUM_H
#include "xed-common-hdrs.h"
typedef enum {
XED_ATTRIBUTE_INVALID,
XED_ATTRIBUTE_ATT_OPERAND_ORDER_EXCEPTION,
XED_ATTRIBUTE_BROADCAST_ENABLED,
XED_ATTRIBUTE_BYTEOP,
XED_ATTRIBUTE_DISP8_EIGHTHMEM,
XED_ATTRIBUTE_DISP8_FULL,
XED_ATTRIBUTE_DISP8_FULLMEM,
XED_ATTRIBUTE_DISP8_GPR_READER,
XED_ATTRIBUTE_DISP8_GPR_READER_BYTE,
XED_ATTRIBUTE_DISP8_GPR_READER_WORD,
XED_ATTRIBUTE_DISP8_GPR_WRITER_LDOP_D,
XED_ATTRIBUTE_DISP8_GPR_WRITER_LDOP_Q,
XED_ATTRIBUTE_DISP8_GPR_WRITER_STORE,
XED_ATTRIBUTE_DISP8_GPR_WRITER_STORE_BYTE,
XED_ATTRIBUTE_DISP8_GPR_WRITER_STORE_WORD,
XED_ATTRIBUTE_DISP8_GSCAT,
XED_ATTRIBUTE_DISP8_HALF,
XED_ATTRIBUTE_DISP8_HALFMEM,
XED_ATTRIBUTE_DISP8_MEM128,
XED_ATTRIBUTE_DISP8_MOVDDUP,
XED_ATTRIBUTE_DISP8_QUARTERMEM,
XED_ATTRIBUTE_DISP8_SCALAR,
XED_ATTRIBUTE_DISP8_TUPLE1,
XED_ATTRIBUTE_DISP8_TUPLE1_4X,
XED_ATTRIBUTE_DISP8_TUPLE1_BYTE,
XED_ATTRIBUTE_DISP8_TUPLE1_WORD,
XED_ATTRIBUTE_DISP8_TUPLE2,
XED_ATTRIBUTE_DISP8_TUPLE4,
XED_ATTRIBUTE_DISP8_TUPLE8,
XED_ATTRIBUTE_DOUBLE_WIDE_MEMOP,
XED_ATTRIBUTE_DOUBLE_WIDE_OUTPUT,
XED_ATTRIBUTE_DWORD_INDICES,
XED_ATTRIBUTE_ELEMENT_SIZE_D,
XED_ATTRIBUTE_ELEMENT_SIZE_Q,
XED_ATTRIBUTE_EXCEPTION_BR,
XED_ATTRIBUTE_FAR_XFER,
XED_ATTRIBUTE_FIXED_BASE0,
XED_ATTRIBUTE_FIXED_BASE1,
XED_ATTRIBUTE_GATHER,
XED_ATTRIBUTE_HALF_WIDE_OUTPUT,
XED_ATTRIBUTE_HLE_ACQ_ABLE,
XED_ATTRIBUTE_HLE_REL_ABLE,
XED_ATTRIBUTE_IGNORES_OSFXSR,
XED_ATTRIBUTE_IMPLICIT_ONE,
XED_ATTRIBUTE_INDEX_REG_IS_POINTER,
XED_ATTRIBUTE_KMASK,
XED_ATTRIBUTE_LOCKABLE,
XED_ATTRIBUTE_LOCKED,
XED_ATTRIBUTE_MASKOP,
XED_ATTRIBUTE_MASKOP_EVEX,
XED_ATTRIBUTE_MASK_AS_CONTROL,
XED_ATTRIBUTE_MASK_VARIABLE_MEMOP,
XED_ATTRIBUTE_MEMORY_FAULT_SUPPRESSION,
XED_ATTRIBUTE_MMX_EXCEPT,
XED_ATTRIBUTE_MPX_PREFIX_ABLE,
XED_ATTRIBUTE_MULTISOURCE4,
XED_ATTRIBUTE_MXCSR,
XED_ATTRIBUTE_MXCSR_RD,
XED_ATTRIBUTE_NONTEMPORAL,
XED_ATTRIBUTE_NOP,
XED_ATTRIBUTE_NOTSX,
XED_ATTRIBUTE_NOTSX_COND,
XED_ATTRIBUTE_NO_RIP_REL,
XED_ATTRIBUTE_PREFETCH,
XED_ATTRIBUTE_PROTECTED_MODE,
XED_ATTRIBUTE_QWORD_INDICES,
XED_ATTRIBUTE_REP,
XED_ATTRIBUTE_REQUIRES_ALIGNMENT,
XED_ATTRIBUTE_RING0,
XED_ATTRIBUTE_SCALABLE,
XED_ATTRIBUTE_SCATTER,
XED_ATTRIBUTE_SIMD_SCALAR,
XED_ATTRIBUTE_SKIPLOW32,
XED_ATTRIBUTE_SKIPLOW64,
XED_ATTRIBUTE_SPECIAL_AGEN_REQUIRED,
XED_ATTRIBUTE_STACKPOP0,
XED_ATTRIBUTE_STACKPOP1,
XED_ATTRIBUTE_STACKPUSH0,
XED_ATTRIBUTE_STACKPUSH1,
XED_ATTRIBUTE_X87_CONTROL,
XED_ATTRIBUTE_X87_MMX_STATE_CW,
XED_ATTRIBUTE_X87_MMX_STATE_R,
XED_ATTRIBUTE_X87_MMX_STATE_W,
XED_ATTRIBUTE_X87_NOWAIT,
XED_ATTRIBUTE_XMM_STATE_CW,
XED_ATTRIBUTE_XMM_STATE_R,
XED_ATTRIBUTE_XMM_STATE_W,
XED_ATTRIBUTE_LAST
} xed_attribute_enum_t;
/// This converts strings to #xed_attribute_enum_t types.
/// @param s A C-string.
/// @return #xed_attribute_enum_t
/// @ingroup ENUM
XED_DLL_EXPORT xed_attribute_enum_t str2xed_attribute_enum_t(const char* s);
/// This converts strings to #xed_attribute_enum_t types.
/// @param p An enumeration element of type xed_attribute_enum_t.
/// @return string
/// @ingroup ENUM
XED_DLL_EXPORT const char* xed_attribute_enum_t2str(const xed_attribute_enum_t p);
/// Returns the last element of the enumeration
/// @return xed_attribute_enum_t The last element of the enumeration.
/// @ingroup ENUM
XED_DLL_EXPORT xed_attribute_enum_t xed_attribute_enum_t_last(void);
#endif
/*BEGIN_LEGAL
Copyright (c) 2016 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 */
#if !defined(XED_ATTRIBUTES_H)
# define XED_ATTRIBUTES_H
#include "xed-types.h"
typedef struct {
xed_uint64_t a1;
xed_uint64_t a2;
} xed_attributes_t;
#endif
#if !defined(XED_BUILD_DEFINES_H)
# define XED_BUILD_DEFINES_H
# if !defined(XED_AMD_ENABLED)
# define XED_AMD_ENABLED
# endif
# if !defined(XED_AVX)
# define XED_AVX
# endif
# if !defined(XED_CET)
# define XED_CET
# endif
# if !defined(XED_DECODER)
# define XED_DECODER
# endif
# if !defined(XED_ENCODER)
# define XED_ENCODER
# endif
# if !defined(XED_GIT_VERSION)
# define XED_GIT_VERSION "v10.0-153-g7888896"
# endif
# if !defined(XED_MPX)
# define XED_MPX
# endif
# if !defined(XED_SUPPORTS_AVX512)
# define XED_SUPPORTS_AVX512
# endif
# if !defined(XED_SUPPORTS_LZCNT_TZCNT)
# define XED_SUPPORTS_LZCNT_TZCNT
# endif
# if !defined(XED_SUPPORTS_SHA)
# define XED_SUPPORTS_SHA
# endif
#endif
/// @file xed-category-enum.h
// This file was automatically generated.
// Do not edit this file.
#if !defined(XED_CATEGORY_ENUM_H)
# define XED_CATEGORY_ENUM_H
#include "xed-common-hdrs.h"
typedef enum {
XED_CATEGORY_INVALID,
XED_CATEGORY_3DNOW,
XED_CATEGORY_AES,
XED_CATEGORY_AVX,
XED_CATEGORY_AVX2,
XED_CATEGORY_AVX2GATHER,
XED_CATEGORY_AVX512,
XED_CATEGORY_AVX512_4FMAPS,
XED_CATEGORY_AVX512_4VNNIW,
XED_CATEGORY_AVX512_VBMI,
XED_CATEGORY_BDW,
XED_CATEGORY_BINARY,
XED_CATEGORY_BITBYTE,
XED_CATEGORY_BLEND,
XED_CATEGORY_BMI1,
XED_CATEGORY_BMI2,
XED_CATEGORY_BROADCAST,
XED_CATEGORY_CALL,
XED_CATEGORY_CET,
XED_CATEGORY_CLFLUSHOPT,
XED_CATEGORY_CLWB,
XED_CATEGORY_CLZERO,
XED_CATEGORY_CMOV,
XED_CATEGORY_COMPRESS,
XED_CATEGORY_COND_BR,
XED_CATEGORY_CONFLICT,
XED_CATEGORY_CONVERT,
XED_CATEGORY_DATAXFER,
XED_CATEGORY_DECIMAL,
XED_CATEGORY_EXPAND,
XED_CATEGORY_FCMOV,
XED_CATEGORY_FLAGOP,
XED_CATEGORY_FMA4,
XED_CATEGORY_GATHER,
XED_CATEGORY_IFMA,
XED_CATEGORY_INTERRUPT,
XED_CATEGORY_IO,
XED_CATEGORY_IOSTRINGOP,
XED_CATEGORY_KMASK,
XED_CATEGORY_LOGICAL,
XED_CATEGORY_LOGICAL_FP,
XED_CATEGORY_LZCNT,
XED_CATEGORY_MISC,
XED_CATEGORY_MMX,
XED_CATEGORY_MPX,
XED_CATEGORY_NOP,
XED_CATEGORY_PCLMULQDQ,
XED_CATEGORY_PKU,
XED_CATEGORY_POP,
XED_CATEGORY_PREFETCH,
XED_CATEGORY_PREFETCHWT1,
XED_CATEGORY_PT,
XED_CATEGORY_PUSH,
XED_CATEGORY_RDRAND,
XED_CATEGORY_RDSEED,
XED_CATEGORY_RDWRFSGS,
XED_CATEGORY_RET,
XED_CATEGORY_ROTATE,
XED_CATEGORY_SCATTER,
XED_CATEGORY_SEGOP,
XED_CATEGORY_SEMAPHORE,
XED_CATEGORY_SETCC,
XED_CATEGORY_SGX,
XED_CATEGORY_SHA,
XED_CATEGORY_SHIFT,
XED_CATEGORY_SMAP,
XED_CATEGORY_SSE,
XED_CATEGORY_STRINGOP,
XED_CATEGORY_STTNI,
XED_CATEGORY_SYSCALL,
XED_CATEGORY_SYSRET,
XED_CATEGORY_SYSTEM,
XED_CATEGORY_TBM,
XED_CATEGORY_UNCOND_BR,
XED_CATEGORY_VFMA,
XED_CATEGORY_VTX,
XED_CATEGORY_WIDENOP,
XED_CATEGORY_X87_ALU,
XED_CATEGORY_XOP,
XED_CATEGORY_XSAVE,
XED_CATEGORY_XSAVEOPT,
XED_CATEGORY_LAST
} xed_category_enum_t;
/// This converts strings to #xed_category_enum_t types.
/// @param s A C-string.
/// @return #xed_category_enum_t
/// @ingroup ENUM
XED_DLL_EXPORT xed_category_enum_t str2xed_category_enum_t(const char* s);
/// This converts strings to #xed_category_enum_t types.
/// @param p An enumeration element of type xed_category_enum_t.
/// @return string
/// @ingroup ENUM
XED_DLL_EXPORT const char* xed_category_enum_t2str(const xed_category_enum_t p);
/// Returns the last element of the enumeration
/// @return xed_category_enum_t The last element of the enumeration.
/// @ingroup ENUM
XED_DLL_EXPORT xed_category_enum_t xed_category_enum_t_last(void);
#endif
/// @file xed-chip-enum.h
// This file was automatically generated.
// Do not edit this file.
#if !defined(XED_CHIP_ENUM_H)
# define XED_CHIP_ENUM_H
#include "xed-common-hdrs.h"
typedef enum {
XED_CHIP_INVALID,
XED_CHIP_I86,
XED_CHIP_I86FP,
XED_CHIP_I186,
XED_CHIP_I186FP,
XED_CHIP_I286REAL,
XED_CHIP_I286,
XED_CHIP_I2186FP,
XED_CHIP_I386REAL,
XED_CHIP_I386,
XED_CHIP_I386FP,
XED_CHIP_I486REAL,
XED_CHIP_I486,
XED_CHIP_PENTIUMREAL,
XED_CHIP_PENTIUM,
XED_CHIP_QUARK,
XED_CHIP_PENTIUMMMXREAL,
XED_CHIP_PENTIUMMMX,
XED_CHIP_ALLREAL,
XED_CHIP_PENTIUMPRO,
XED_CHIP_PENTIUM2,
XED_CHIP_PENTIUM3,
XED_CHIP_PENTIUM4,
XED_CHIP_P4PRESCOTT,
XED_CHIP_P4PRESCOTT_NOLAHF,
XED_CHIP_P4PRESCOTT_VTX,
XED_CHIP_CORE2,
XED_CHIP_PENRYN,
XED_CHIP_PENRYN_E,
XED_CHIP_NEHALEM,
XED_CHIP_WESTMERE,
XED_CHIP_BONNELL,
XED_CHIP_SALTWELL,
XED_CHIP_SILVERMONT,
XED_CHIP_AMD,
XED_CHIP_GOLDMONT,
XED_CHIP_SANDYBRIDGE,
XED_CHIP_IVYBRIDGE,
XED_CHIP_HASWELL,
XED_CHIP_BROADWELL,
XED_CHIP_SKYLAKE,
XED_CHIP_SKYLAKE_SERVER,
XED_CHIP_MEMORY_FUTURE,
XED_CHIP_FUTURE,
XED_CHIP_KNL,
XED_CHIP_KNM,
XED_CHIP_AVX512_FUTURE,
XED_CHIP_ALL,
XED_CHIP_LAST
} xed_chip_enum_t;
/// This converts strings to #xed_chip_enum_t types.
/// @param s A C-string.
/// @return #xed_chip_enum_t
/// @ingroup ENUM
XED_DLL_EXPORT xed_chip_enum_t str2xed_chip_enum_t(const char* s);
/// This converts strings to #xed_chip_enum_t types.
/// @param p An enumeration element of type xed_chip_enum_t.
/// @return string
/// @ingroup ENUM
XED_DLL_EXPORT const char* xed_chip_enum_t2str(const xed_chip_enum_t p);
/// Returns the last element of the enumeration
/// @return xed_chip_enum_t The last element of the enumeration.
/// @ingroup ENUM
XED_DLL_EXPORT xed_chip_enum_t xed_chip_enum_t_last(void);
#endif
/*BEGIN_LEGAL
Copyright (c) 2016 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 */
#if !defined(XED_CHIP_FEATURES_H)
# define XED_CHIP_FEATURES_H
#include "xed-common-hdrs.h"
#include "xed-types.h"
#include "xed-isa-set-enum.h" /* generated */
#include "xed-chip-enum.h" /* generated */
#define XED_FEATURE_VECTOR_MAX 4
/// @ingroup ISASET
typedef struct
{
xed_uint64_t f[XED_FEATURE_VECTOR_MAX];
} xed_chip_features_t;
/// fill in the contents of p with the vector of chip features.
XED_DLL_EXPORT void
xed_get_chip_features(xed_chip_features_t* p, xed_chip_enum_t chip);
/// present = 1 to turn the feature on. present=0 to remove the feature.
XED_DLL_EXPORT void
xed_modify_chip_features(xed_chip_features_t* p,
xed_isa_set_enum_t isa_set,
xed_bool_t present);
#endif
/*BEGIN_LEGAL
Copyright (c) 2016 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 */
/// @file xed-common-defs.h
/// @brief some pervasive defines
#ifndef XED_COMMON_DEFS_H
# define XED_COMMON_DEFS_H
// for most things it is 4, but one 64b mov allows 8
#define XED_MAX_DISPLACEMENT_BYTES 8
// for most things it is max 4, but one 64b mov allows 8.
#define XED_MAX_IMMEDIATE_BYTES 8
#define XED_MAX_INSTRUCTION_BYTES 15
#define XED_BYTE_MASK(x) ((x) & 0xFF)
#define XED_BYTE_CAST(x) (XED_STATIC_CAST(xed_uint8_t,x))
#endif
/*BEGIN_LEGAL
Copyright (c) 2016 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 */
/// @file xed-common-hdrs.h
///
#ifndef XED_COMMON_HDRS_H
# define XED_COMMON_HDRS_H
#if defined(__FreeBSD__) || defined(__NetBSD__)
# define XED_BSD
#endif
#if defined(__linux__)
# define XED_LINUX
#endif
#if defined(_MSC_VER)
# define XED_WINDOWS
#endif
#if defined(__APPLE__)
# define XED_MAC
#endif
#if defined(XED_DLL)
// __declspec(dllexport) works with GNU GCC or MS compilers, but not ICC
// on linux
# if defined(XED_WINDOWS)
# define XED_DLL_EXPORT __declspec(dllexport)
# define XED_DLL_IMPORT __declspec(dllimport)
# elif defined(XED_LINUX) || defined(XED_BSD) || defined(XED_MAC)
# define XED_DLL_EXPORT __attribute__((visibility("default")))
# define XED_DLL_IMPORT
# else
# define XED_DLL_EXPORT
# define XED_DLL_IMPORT
# endif
# if defined(XED_BUILD)
/* when building XED, we export symbols */
# define XED_DLL_GLOBAL XED_DLL_EXPORT
# else
/* when building XED clients, we import symbols */
# define XED_DLL_GLOBAL XED_DLL_IMPORT
# endif