BOAST 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59589a610dd30134353d9aa38e9ea1de00b43a9a
4
- data.tar.gz: 4eec51beee55795b76432c1c4b12502113a7fe3f
3
+ metadata.gz: 939618b7050d9d0298fa5f06b310ac5a881b85ef
4
+ data.tar.gz: 60b1fc0bc92e9b1dad4003604a30c9f4de634d87
5
5
  SHA512:
6
- metadata.gz: a190b47611875b112f027e5b3e4bf292d331f4029ee47d581493fd6d3d4c88d807f98b91887f7602a9e922a2744f48d5965de4f5ce7103597b52886a5eea6f02
7
- data.tar.gz: 24c85287f04dae5ce701e11099ef562fb97e81f89fc7ca15105593dee7746a141d1124ab7e1d593193e63f5aeb56bb598a2c986f6c470a91b4fe6b8cfd4c5527
6
+ metadata.gz: cc1877354a30495b196128bd5e94055808197c14e9e7d6fd9dbb8c1e6c6dc603efbd5a877fd6d64f4d7f12b0fe88a0a8c1801cacb3baf13d206d25740914af4e
7
+ data.tar.gz: 858093b8d634b8f0ff61f90aa5a2b7a8d67c5b49e9013cdc4093a453095adfaf9ba3490ad8548082b1bd0728cd280184a2ccacf147d94dcdbf541fff124217ec
data/BOAST.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'BOAST'
3
- s.version = "1.1.0"
3
+ s.version = "1.2.0"
4
4
  s.author = "Brice Videau"
5
5
  s.email = "brice.videau@imag.fr"
6
6
  s.homepage = "https://github.com/Nanosim-LIG/boast"
@@ -75,14 +75,15 @@ module BOAST
75
75
  attr_reader :expression
76
76
  attr_reader :case_conditions
77
77
 
78
- def initialize(expression, *control, &block)
78
+ def initialize(expression, control = {}, &block)
79
79
  @expression = expression
80
80
  @case_conditions = []
81
- control.push(block) if block
82
- while control.size >= 2 do
83
- @case_conditions.push CaseCondition::new([control.shift].flatten, &(control.shift))
84
- end
85
- @case_conditions.push CaseCondition::new(&(control.shift)) if control.size > 0
81
+ default = control.delete(:default)
82
+ default = block unless default or not block
83
+ control.each { |key, value|
84
+ @case_conditions.push CaseCondition::new( [key].flatten, &value )
85
+ }
86
+ @case_conditions.push CaseCondition::new( &default ) if default
86
87
  end
87
88
 
88
89
  def get_c_strings
@@ -4,19 +4,20 @@ module BOAST
4
4
 
5
5
  attr_reader :conditions
6
6
 
7
- def initialize(*conditions, &block)
8
- raise "Illegal if construct!" if conditions.size == 0
9
- conditions.push(block) if block
7
+ def initialize(conditions, &block)
10
8
  @conditions = []
11
9
  @blocks = []
12
- if conditions.size == 1 then
13
- @conditions.push conditions.shift
10
+ if conditions.is_a?(Hash) then
11
+ else_block = conditions.delete(:else)
12
+ else_block = block unless else_block or not block
13
+ conditions.each { |key, value|
14
+ @conditions.push key
15
+ @blocks.push value
16
+ }
17
+ @blocks.push else_block if else_block
14
18
  else
15
- while conditions.size >= 2 do
16
- @conditions.push conditions.shift
17
- @blocks.push conditions.shift
18
- end
19
- @blocks.push conditions.shift if conditions.size > 0
19
+ @conditions.push conditions
20
+ @blocks.push block if block
20
21
  end
21
22
  end
22
23
 
@@ -8,15 +8,22 @@ module BOAST
8
8
  X86 = 1
9
9
  ARM = 2
10
10
 
11
- native_flags = nil
11
+ native_flags = []
12
12
 
13
13
  if OS.mac? then
14
14
  native_flags = `sysctl -n machdep.cpu.features`.split
15
15
  else
16
- native_flags = YAML::load(`cat /proc/cpuinfo`)["flags"].upcase.gsub("_",".").split
16
+ yaml_cpuinfo = YAML::load(`cat /proc/cpuinfo`)
17
+ cpuinfo_flags = yaml_cpuinfo["flags"]
18
+ cpuinfo_flags = yaml_cpuinfo["Features"] unless cpuinfo_flags
19
+ if cpuinfo_flags then
20
+ native_flags = cpuinfo_flags.upcase.gsub("_",".").split
21
+ else
22
+ warn "Unable to determine architecture flags for native!"
23
+ end
17
24
  end
18
25
 
19
- MODELS={ "native" => native_flags }
26
+ MODELS = { "native" => native_flags }
20
27
  MODELS.update(X86architectures)
21
28
  INSTRUCTIONS = {}
22
29
  INSTRUCTIONS.update(X86CPUID_by_name)
@@ -38,11 +45,9 @@ module BOAST
38
45
  else
39
46
  instruction = INTRINSICS[get_architecture][intr_symbol][type]
40
47
  end
48
+ return instruction if get_architecture == ARM
41
49
  raise IntrinsicsError, "Unsupported operation #{intr_symbol} for #{type}#{type2 ? "and #{type2}" : ""} on #{get_architecture_name}!" unless instruction
42
- supported = false
43
- INSTRUCTIONS[instruction.to_s].each { |flag|
44
- supported = true if MODELS[get_model].include?(flag)
45
- }
50
+ supported = (INSTRUCTIONS[instruction.to_s] & MODELS[get_model.to_s]).size > 0
46
51
  raise IntrinsicsError, "Unsupported operation #{intr_symbol} for #{type}#{type2 ? "and #{type2}" : ""} on #{get_model}! (requires #{INSTRUCTIONS[instruction.to_s].join(" or ")})" unless supported
47
52
  return instruction
48
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BOAST
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Videau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray