impc:ir:compiler:if   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/llvmir.xtm

Implementation

;; if that might need to return a value
(define impc:ir:compiler:if
  (lambda (ast types . hint?)
    ;; (println 'ast: ast)
    (let* ((os (make-string 0))
           (elset (if (or (null? (cdddr ast))
                          (null? (cadddr ast)))
                      #f #t))
           (num (number->string (llvm:count++))))
      ;; first do compare expression
      (emit (impc:ir:compiler (cadr ast) types) os)
      ;; then break on compare
      (emit (string-append "br i1 " (car (impc:ir:gname)) ", label %then" num ", "
                           "label %else" num "\n") os)
      ;; do then
      (emit  "\nthen" num ":\n" os)
      (if (not (null? hint?))
          (emit (impc:ir:compiler (caddr ast) types (car hint?)) os)
          (emit (impc:ir:compiler (caddr ast) types) os))
      (if (not (impc:ir:void? (cadr (impc:ir:gname))))
          (emit (string-append "store " (cadr (impc:ir:gname)) " " (car (impc:ir:gname))
                               ", " (cadr (impc:ir:gname)) "* %ifptr" num "\n") os))
      (emit  "br label %ifcont" num "\n" os)
      (define a (impc:ir:gname))
      ;; do else if requried
      (if elset
          (begin (emit  "\nelse" num ":\n" os)
                 (if (not (null? hint?))
                     (emit (impc:ir:compiler (cadddr ast) types (car hint?)) os)
                     (emit (impc:ir:compiler (cadddr ast) types) os))
                 (if (not (impc:ir:void? (cadr (impc:ir:gname))))
                     (emit (string-append "store " (cadr (impc:ir:gname)) " " (car (impc:ir:gname))
                                          ", " (cadr (impc:ir:gname)) "* %ifptr" num "\n") os))
                 (emit  "br label %ifcont" num "\n" os))
          (begin (emit  "\nelse" num ":\n" os)
                 (emit  "br label %ifcont" num "\n" os)))


Back to Index

Similar Entries

  • AudioBuffer_from_aiff    xtlang
  • aiff_validate    xtlang
  • analogue_oxygene_riff    xtlang
  • audiofile_aiff_read_samples    xtlang
  • cl:delete-if    scheme
  • cl:delete-if-not    scheme
  • cl:find-if    scheme
  • cl:member-if    scheme
  • cl:remove-if    scheme
  • cl:remove-if-not    scheme
  • cl:set-difference    scheme
  • diff    macro
  • difference    scheme
  • fluid-diffuse    xtlang
  • fluid-diffuse    xtlang
  • fluid_diffuse    xtlang
  • get_frame_identifiers    xtlang
  • get_identifier    xtlang
  • get_life_span_handler    xtlang
  • iffchunk_check_ID    xtlang
  • iffchunk_find_dumb    xtlang
  • iffchunk_find_smart    xtlang
  • iffchunk_size    xtlang
  • ifft    xtlang
  • ifft    xtlang
  • ifft_config    xtlang
  • ifftr_config    xtlang
  • impc:compiler:print-if-type-conflict-error    scheme
  • impc:compiler:print-missing-identifier-error    scheme
  • impc:compiler:print-no-scheme-stub-notification    scheme
  • impc:ir:compiler:ifret    scheme
  • impc:ir:genericfunc-stringify-generic-arg-strings    scheme
  • impc:ti:check-bang-against-reified    scheme
  • impc:ti:complex-unify    scheme
  • impc:ti:construct-generic-type-if-valid    scheme
  • impc:ti:if-check    scheme
  • impc:ti:reify-generic-type    scheme
  • impc:ti:reify-generic-type-expand    scheme
  • impc:ti:reverse-set-bangs-from-reified    scheme
  • impc:ti:simplify-genericfunc-pretty-type    scheme
  • impc:ti:simplify-generictype-pretty-type    scheme
  • impc:ti:sym-unify    scheme
  • impc:ti:type-unify    scheme
  • impc:ti:type-unify-closure    scheme
  • impc:ti:unify    scheme
  • impc:ti:unify-lists    scheme
  • lift    xtlang
  • ndiff    xtlang
  • ndiff    xtlang
  • ndiff2    xtlang
  • ndiff2    xtlang
  • ndiff_extrapolated    xtlang
  • ndifferentiate    xtlang
  • ocv_absdiff    xtlang
  • p:if-matches    scheme
  • scientific-pitch-notation-to-midi-number    scheme
  • simplify    macro
  • stringify    xtlang
  • stringify    xtlang
  • stringify    xtlang
  • stringify    xtlang
  • stringify    xtlang
  • stringify    xtlang
  • xtm_light_diffuse    xtlang
  • xtm_mesh_diffuse    xtlang