Allow both x86 backends to be included, selected with a "variant" flag. (#2514)

This PR adds a new `isa::lookup_variant()` that takes a `BackendVariant`
(`Legacy`, `MachInst` or `Any`), and exposes both x86 backends as
separate variants if both are compiled into the build.

This will allow some new use-cases that require both backends in the
same process: for example, differential fuzzing between old and new
backends, or perhaps allowing for dynamic feature-flag selection between
the backends.
This commit is contained in:
Chris Fallin
2020-12-16 07:56:04 -08:00
committed by GitHub
parent 245abc2bb2
commit e91987c43c
4 changed files with 67 additions and 32 deletions

View File

@@ -250,7 +250,7 @@ mod tests {
use crate::ir::{
types, AbiParam, ExternalName, InstBuilder, Signature, StackSlotData, StackSlotKind,
};
use crate::isa::{lookup, CallConv};
use crate::isa::{lookup_variant, BackendVariant, CallConv};
use crate::settings::{builder, Flags};
use crate::Context;
use std::str::FromStr;
@@ -258,7 +258,7 @@ mod tests {
#[test]
fn test_small_alloc() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));
@@ -314,7 +314,7 @@ mod tests {
#[test]
fn test_medium_alloc() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));
@@ -370,7 +370,7 @@ mod tests {
#[test]
fn test_large_alloc() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));
@@ -442,7 +442,7 @@ mod tests {
#[test]
fn test_multi_return_func() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));

View File

@@ -134,7 +134,7 @@ mod tests {
use crate::ir::{
types, AbiParam, ExternalName, InstBuilder, Signature, StackSlotData, StackSlotKind,
};
use crate::isa::{lookup, CallConv};
use crate::isa::{lookup_variant, BackendVariant, CallConv};
use crate::settings::{builder, Flags};
use crate::Context;
use gimli::write::Address;
@@ -143,7 +143,7 @@ mod tests {
#[test]
fn test_simple_func() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));
@@ -185,7 +185,7 @@ mod tests {
#[test]
fn test_multi_return_func() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));

View File

@@ -46,7 +46,7 @@ mod tests {
use crate::ir::{ExternalName, InstBuilder, Signature, StackSlotData, StackSlotKind};
use crate::isa::unwind::winx64::UnwindCode;
use crate::isa::x86::registers::RU;
use crate::isa::{lookup, CallConv};
use crate::isa::{lookup_variant, BackendVariant, CallConv};
use crate::settings::{builder, Flags};
use crate::Context;
use std::str::FromStr;
@@ -54,7 +54,7 @@ mod tests {
#[test]
fn test_wrong_calling_convention() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));
@@ -70,7 +70,7 @@ mod tests {
#[test]
fn test_small_alloc() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));
@@ -127,7 +127,7 @@ mod tests {
#[test]
fn test_medium_alloc() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));
@@ -188,7 +188,7 @@ mod tests {
#[test]
fn test_large_alloc() {
let isa = lookup(triple!("x86_64"))
let isa = lookup_variant(triple!("x86_64"), BackendVariant::Legacy)
.expect("expect x86 ISA")
.finish(Flags::new(builder()));