Skip to content

Commit ae20c8d

Browse files
deps: Update to bitflags 2 from 1.
This has a change in behavior where calling `Flags::make` or `Feature::make` will ignore any unknown bits where before they were transparently maintained.
1 parent 8cf3a11 commit ae20c8d

File tree

2 files changed

+56
-54
lines changed

2 files changed

+56
-54
lines changed

plugin/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ proc-macro = true
1919

2020
[dependencies]
2121
lazy_static = "1"
22-
bitflags = "1.1.0"
22+
bitflags = "2"
2323
byteorder = "1"
2424
quote = "1"
2525
proc-macro-error = "1"

plugin/src/arch/x64/x64data.rs

+55-53
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub fn get_mnemnonic_data(name: &str) -> Option<&'static [Opdata]> {
3636
}
3737

3838
bitflags! {
39+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
3940
pub struct Flags: u32 {
4041
const DEFAULT = 0x0000_0000; // this instruction has default encoding
4142
const VEX_OP = 0x0000_0001; // this instruction requires a VEX prefix to be encoded
@@ -72,11 +73,12 @@ bitflags! {
7273

7374
impl Flags {
7475
const fn make(bits: u32) -> Flags {
75-
Flags { bits }
76+
Flags::from_bits_truncate(bits)
7677
}
7778
}
7879

7980
bitflags! {
81+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
8082
pub struct Features: u32 {
8183
const X64_IMPLICIT = 0x0000_0000;
8284
const FPU = 0x0000_0001;
@@ -109,7 +111,7 @@ bitflags! {
109111

110112
impl Features {
111113
const fn make(bits: u32) -> Features {
112-
Features { bits }
114+
Features::from_bits_truncate(bits)
113115
}
114116

115117
pub fn from_str(name: &str) -> Option<Features> {
@@ -188,59 +190,59 @@ pub fn mnemnonics() -> hash_map::Keys<'static, &'static str, &'static [Opdata]>
188190
}
189191

190192
// workaround until bitflags can be used in const
191-
const DEFAULT : u32 = Flags::DEFAULT.bits;
192-
const VEX_OP : u32 = Flags::VEX_OP.bits;
193-
const XOP_OP : u32 = Flags::XOP_OP.bits;
194-
const IMM_OP : u32 = Flags::IMM_OP.bits;
195-
const SHORT_ARG : u32 = Flags::SHORT_ARG.bits;
196-
const AUTO_SIZE : u32 = Flags::AUTO_SIZE.bits;
197-
const AUTO_NO32 : u32 = Flags::AUTO_NO32.bits;
198-
const AUTO_REXW : u32 = Flags::AUTO_REXW.bits;
199-
const AUTO_VEXL : u32 = Flags::AUTO_VEXL.bits;
200-
const WORD_SIZE : u32 = Flags::WORD_SIZE.bits;
201-
const WITH_REXW : u32 = Flags::WITH_REXW.bits;
202-
const WITH_VEXL : u32 = Flags::WITH_VEXL.bits;
203-
const EXACT_SIZE : u32 = Flags::EXACT_SIZE.bits;
204-
const PREF_66 : u32 = Flags::PREF_66.bits;
205-
const PREF_67 : u32 = Flags::PREF_67.bits;
206-
const PREF_F0 : u32 = Flags::PREF_F0.bits;
207-
const PREF_F2 : u32 = Flags::PREF_F2.bits;
208-
const PREF_F3 : u32 = Flags::PREF_F3.bits;
209-
const LOCK : u32 = Flags::LOCK.bits;
210-
const REP : u32 = Flags::REP.bits;
211-
const REPE : u32 = Flags::REPE.bits;
212-
const ENC_MR : u32 = Flags::ENC_MR.bits;
213-
const ENC_VM : u32 = Flags::ENC_VM.bits;
214-
const ENC_MIB : u32 = Flags::ENC_MIB.bits;
215-
const X86_ONLY : u32 = Flags::X86_ONLY.bits;
193+
const DEFAULT : u32 = Flags::DEFAULT.bits();
194+
const VEX_OP : u32 = Flags::VEX_OP.bits();
195+
const XOP_OP : u32 = Flags::XOP_OP.bits();
196+
const IMM_OP : u32 = Flags::IMM_OP.bits();
197+
const SHORT_ARG : u32 = Flags::SHORT_ARG.bits();
198+
const AUTO_SIZE : u32 = Flags::AUTO_SIZE.bits();
199+
const AUTO_NO32 : u32 = Flags::AUTO_NO32.bits();
200+
const AUTO_REXW : u32 = Flags::AUTO_REXW.bits();
201+
const AUTO_VEXL : u32 = Flags::AUTO_VEXL.bits();
202+
const WORD_SIZE : u32 = Flags::WORD_SIZE.bits();
203+
const WITH_REXW : u32 = Flags::WITH_REXW.bits();
204+
const WITH_VEXL : u32 = Flags::WITH_VEXL.bits();
205+
const EXACT_SIZE : u32 = Flags::EXACT_SIZE.bits();
206+
const PREF_66 : u32 = Flags::PREF_66.bits();
207+
const PREF_67 : u32 = Flags::PREF_67.bits();
208+
const PREF_F0 : u32 = Flags::PREF_F0.bits();
209+
const PREF_F2 : u32 = Flags::PREF_F2.bits();
210+
const PREF_F3 : u32 = Flags::PREF_F3.bits();
211+
const LOCK : u32 = Flags::LOCK.bits();
212+
const REP : u32 = Flags::REP.bits();
213+
const REPE : u32 = Flags::REPE.bits();
214+
const ENC_MR : u32 = Flags::ENC_MR.bits();
215+
const ENC_VM : u32 = Flags::ENC_VM.bits();
216+
const ENC_MIB : u32 = Flags::ENC_MIB.bits();
217+
const X86_ONLY : u32 = Flags::X86_ONLY.bits();
216218

217219
#[allow(dead_code)]
218-
const X64_IMPLICIT : u32 = Features::X64_IMPLICIT.bits;
219-
const FPU : u32 = Features::FPU.bits;
220-
const MMX : u32 = Features::MMX.bits;
221-
const TDNOW : u32 = Features::TDNOW.bits;
222-
const SSE : u32 = Features::SSE.bits;
223-
const SSE2 : u32 = Features::SSE2.bits;
224-
const SSE3 : u32 = Features::SSE3.bits;
225-
const VMX : u32 = Features::VMX.bits;
226-
const SSSE3 : u32 = Features::SSSE3.bits;
227-
const SSE4A : u32 = Features::SSE4A.bits;
228-
const SSE41 : u32 = Features::SSE41.bits;
229-
const SSE42 : u32 = Features::SSE42.bits;
230-
const SSE5 : u32 = Features::SSE5.bits;
231-
const AVX : u32 = Features::AVX.bits;
232-
const AVX2 : u32 = Features::AVX2.bits;
233-
const FMA : u32 = Features::FMA.bits;
234-
const BMI1 : u32 = Features::BMI1.bits;
235-
const BMI2 : u32 = Features::BMI2.bits;
236-
const TBM : u32 = Features::TBM.bits;
237-
const RTM : u32 = Features::RTM.bits;
238-
const INVPCID : u32 = Features::INVPCID.bits;
239-
const MPX : u32 = Features::MPX.bits;
240-
const SHA : u32 = Features::SHA.bits;
241-
const PREFETCHWT1 : u32 = Features::PREFETCHWT1.bits;
242-
const CYRIX : u32 = Features::CYRIX.bits;
243-
const AMD : u32 = Features::AMD.bits;
220+
const X64_IMPLICIT : u32 = Features::X64_IMPLICIT.bits();
221+
const FPU : u32 = Features::FPU.bits();
222+
const MMX : u32 = Features::MMX.bits();
223+
const TDNOW : u32 = Features::TDNOW.bits();
224+
const SSE : u32 = Features::SSE.bits();
225+
const SSE2 : u32 = Features::SSE2.bits();
226+
const SSE3 : u32 = Features::SSE3.bits();
227+
const VMX : u32 = Features::VMX.bits();
228+
const SSSE3 : u32 = Features::SSSE3.bits();
229+
const SSE4A : u32 = Features::SSE4A.bits();
230+
const SSE41 : u32 = Features::SSE41.bits();
231+
const SSE42 : u32 = Features::SSE42.bits();
232+
const SSE5 : u32 = Features::SSE5.bits();
233+
const AVX : u32 = Features::AVX.bits();
234+
const AVX2 : u32 = Features::AVX2.bits();
235+
const FMA : u32 = Features::FMA.bits();
236+
const BMI1 : u32 = Features::BMI1.bits();
237+
const BMI2 : u32 = Features::BMI2.bits();
238+
const TBM : u32 = Features::TBM.bits();
239+
const RTM : u32 = Features::RTM.bits();
240+
const INVPCID : u32 = Features::INVPCID.bits();
241+
const MPX : u32 = Features::MPX.bits();
242+
const SHA : u32 = Features::SHA.bits();
243+
const PREFETCHWT1 : u32 = Features::PREFETCHWT1.bits();
244+
const CYRIX : u32 = Features::CYRIX.bits();
245+
const AMD : u32 = Features::AMD.bits();
244246

245247

246248
lazy_static! {

0 commit comments

Comments
 (0)