Skip to content

Commit e205fc4

Browse files
authored
removes the special Primus Lisp primitive (#1477)
* unifies name generation for IR subroutines It turned out that empty subroutines and non-empty subroutines could have had different names. * implements a new naming scheme for interrupts * removes the special Primus Lisp primitive This primitive is now fully subsumed by the `intrinsic` primitive so there's no need to have two names for the same thing. To update the existing code that uses special, substitute every occurence of `(special :foo)` with `(intrinsic 'foo)`
1 parent 5b7d9a2 commit e205fc4

File tree

6 files changed

+14
-28
lines changed

6 files changed

+14
-28
lines changed

lib/bap_sema/bap_sema_lift.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ let link_call symtab addr sub_of_blk jmp =
333333

334334
let is_intrinsic sub =
335335
match KB.Name.package @@ KB.Name.read (Ir_sub.name sub) with
336-
| "intrinsic" | "special" -> true
336+
| "intrinsic" -> true
337337
| _ -> false
338338

339339
let create_synthetic tid =

plugins/arm/semantics/aarch64-atomic.lisp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
acquire and release are booleans indicating whether load-acquire and
1313
store-release ordering is to be enforced."
1414
(let ((data (load rn)))
15-
(when acquire (special :load-acquire))
15+
(when acquire (intrinsic 'load-acquire))
1616
(when (= data rs)
17-
(when release (special :store-release))
17+
(when release (intrinsic 'store-release))
1818
(store rn rt))
1919
(set rs data)))
2020

@@ -79,4 +79,4 @@
7979
(defun CSINVWr (rd rn rm cnd) (CSop*r setw lnot rd rn rm cnd))
8080
(defun CSINVXr (rd rn rm cnd) (CSop*r set$ lnot rd rn rm cnd))
8181
(defun CSNEGWr (rd rn rm cnd) (CSop*r setw neg rd rn rm cnd)) ;; 2's complement negation
82-
(defun CSNEGXr (rd rn rm cnd) (CSop*r set$ neg rd rn rm cnd)) ;; 2's complement negation
82+
(defun CSNEGXr (rd rn rm cnd) (CSop*r set$ neg rd rn rm cnd)) ;; 2's complement negation

plugins/arm/semantics/aarch64-special.lisp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
;;; SPECIAL INSTRUCTIONS
66

77
(defun make-barrier (barrier-type option)
8-
(special (symbol-concat :barrier barrier-type (barrier-option-to-symbol option))))
8+
(intrinsic (symbol-concat 'barrier
9+
barrier-type
10+
(barrier-option-to-symbol option))))
911

10-
(defun DMB (option) (make-barrier :dmb option))
12+
(defun DMB (option) (make-barrier 'dmb option))
1113

12-
(defun DSB (option) (make-barrier :dsb option))
14+
(defun DSB (option) (make-barrier 'dsb option))
1315

1416
;; strictly speaking, only the sy option is valid and is
1517
;; the default option (it can be omitted from the mnemonic).
1618
;; still including option here though
17-
(defun ISB (option) (make-barrier :isb option))
19+
(defun ISB (option) (make-barrier 'isb option))
1820

1921
(defun HINT (_)
2022
(empty))
2123

2224
(defun UDF (exn)
23-
(special :undefined-instruction))
25+
(intrinsic 'undefined-instruction))

plugins/primus_lisp/primus_lisp_semantic_primitives.ml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,6 @@ let export = Primus.Lisp.Type.Spec.[
241241
The function is equivalent to (select N X)";
242242
"empty", (unit @-> any),
243243
"(empty) denotes an instruction that does nothing, i.e., a nop.";
244-
"special", (one sym @-> any),
245-
"(special :NAME) produces a special effect denoted by the keyword :NAME.
246-
The effect will be reified into the to the special:name subroutine. ";
247244
"intrinsic", tuple [sym] // all any @-> any,
248245
"(intrinsic 'NAME ARG1 ARG2 ... ARGN PARAMS..) produces a call to
249246
an intrinsic function with the given NAME. Arguments could be
@@ -820,15 +817,6 @@ module Primitives(CT : Theory.Core)(T : Target) = struct
820817
| Some _ -> true_
821818
| _ -> false_
822819

823-
let is_keyword = String.is_prefix ~prefix:":"
824-
825-
let special dst =
826-
require_symbol dst @@ fun dst ->
827-
if is_keyword dst then
828-
let* dst = Theory.Label.for_name ("special"^dst) in
829-
CT.goto dst
830-
else illformed "special requires a keyword as the tag, e.g., :hlt"
831-
832820
let invoke_subroutine dst =
833821
require_symbol dst @@ fun dst ->
834822
let* dst = Theory.Label.for_name dst in
@@ -992,7 +980,6 @@ module Primitives(CT : Theory.Core)(T : Target) = struct
992980
| ("select"|"nth"),xs -> pure@@select s xs
993981
| "empty",[] -> nop ()
994982
| "intrinsic",(dst::args) -> Intrinsic.call t dst args
995-
| "special",[dst] -> ctrl@@special dst
996983
| "invoke-subroutine",[dst] -> ctrl@@invoke_subroutine dst
997984
| _ -> !!nothing
998985
end

plugins/relocatable/rel_symbolizer.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,8 @@ let plt_size label =
163163
List.find_map plt_sizes ~f:(fun (p,s) ->
164164
Option.some_if (Theory.Target.belongs p t) s)
165165

166-
let is_intrinsic name =
167-
List.exists ~f:(fun prefix -> String.is_prefix ~prefix name) [
168-
"intrinsic:";
169-
"special:";
170-
]
166+
let is_intrinsic =
167+
String.is_prefix ~prefix:"intrinsic:"
171168

172169
let demangle s = match String.chop_suffix ~suffix:":external" s with
173170
| None -> s

plugins/x86/semantics/x86-common.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(in-package x86-common)
1010

1111
(defun HLT ()
12-
(special :hlt))
12+
(intrinsic 'hlt))
1313

1414
(defun NOOP ()
1515
(empty))

0 commit comments

Comments
 (0)