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    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • aiff_validate    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • analogue_oxygene_riff    xtlang    /digego/extempore/tree/v0.8.9/examples/core/covers.xtm
  • audiofile_aiff_read_samples    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • cl:delete-if    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • cl:delete-if-not    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • cl:find-if    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • cl:member-if    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • cl:remove-if    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • cl:remove-if-not    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • cl:set-difference    scheme    /digego/extempore/tree/v0.8.9/runtime/scheme.xtm
  • diff    macro    /digego/extempore/tree/v0.8.9/libs/contrib/cas.xtm
  • difference    scheme    /digego/extempore/tree/v0.8.9/libs/core/pattern-language.xtm
  • fluid-diffuse    xtlang    /digego/extempore/tree/v0.8.9/libs/external/fluid2d.xtm
  • fluid-diffuse    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/fluid_dynamics.xtm
  • fluid_diffuse    xtlang    /digego/extempore/tree/v0.8.9/examples/contrib/fluids_2d.xtm
  • get_frame_identifiers    xtlang    /digego/extempore/tree/v0.8.9/libs/external/cef/cef.xtm
  • get_identifier    xtlang    /digego/extempore/tree/v0.8.9/libs/external/cef/cef.xtm
  • get_life_span_handler    xtlang    /digego/extempore/tree/v0.8.9/libs/external/cef/cef.xtm
  • iffchunk_check_ID    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • iffchunk_find_dumb    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • iffchunk_find_smart    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • iffchunk_size    xtlang    /digego/extempore/tree/v0.8.9/libs/core/audiobuffer.xtm
  • ifft    xtlang    /digego/extempore/tree/v0.8.9/libs/external/fft.xtm
  • ifft    xtlang    /digego/extempore/tree/v0.8.9/libs/external/fft.xtm
  • ifft_config    xtlang    /digego/extempore/tree/v0.8.9/libs/external/fft.xtm
  • ifftr_config    xtlang    /digego/extempore/tree/v0.8.9/libs/external/fft.xtm
  • impc:compiler:print-if-type-conflict-error    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:compiler:print-missing-identifier-error    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:compiler:print-no-scheme-stub-notification    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ir:compiler:ifret    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmir.xtm
  • impc:ir:genericfunc-stringify-generic-arg-strings    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:check-bang-against-reified    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:complex-unify    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:construct-generic-type-if-valid    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:if-check    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:reify-generic-type    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:reify-generic-type-expand    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:reverse-set-bangs-from-reified    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:simplify-genericfunc-pretty-type    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:simplify-generictype-pretty-type    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:sym-unify    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:type-unify    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:type-unify-closure    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:unify    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • impc:ti:unify-lists    scheme    /digego/extempore/tree/v0.8.9/runtime/llvmti.xtm
  • lift    xtlang    /digego/extempore/tree/v0.8.9/examples/core/audio_streams.xtm
  • ndiff    xtlang    /digego/extempore/tree/v0.8.9/libs/core/math.xtm
  • ndiff    xtlang    /digego/extempore/tree/v0.8.9/libs/core/math.xtm
  • ndiff2    xtlang    /digego/extempore/tree/v0.8.9/libs/core/math.xtm
  • ndiff2    xtlang    /digego/extempore/tree/v0.8.9/libs/core/math.xtm
  • ndiff_extrapolated    xtlang    /digego/extempore/tree/v0.8.9/libs/core/math.xtm
  • ndifferentiate    xtlang    /digego/extempore/tree/v0.8.9/libs/core/math.xtm
  • ocv_absdiff    xtlang    /digego/extempore/tree/v0.8.9/libs/contrib/xtmcv.xtm
  • p:if-matches    scheme    /digego/extempore/tree/v0.8.9/libs/base/pattern.xtm
  • scientific-pitch-notation-to-midi-number    scheme    /digego/extempore/tree/v0.8.9/libs/external/instruments_ext-scm.xtm
  • simplify    macro    /digego/extempore/tree/v0.8.9/libs/contrib/cas.xtm
  • stringify    xtlang    /digego/extempore/tree/v0.8.9/tests/core/expr_problem.xtm
  • stringify    xtlang    /digego/extempore/tree/v0.8.9/tests/core/expr_problem.xtm
  • stringify    xtlang    /digego/extempore/tree/v0.8.9/tests/core/expr_problem.xtm
  • stringify    xtlang    /digego/extempore/tree/v0.8.9/examples/core/expr_problem.xtm
  • stringify    xtlang    /digego/extempore/tree/v0.8.9/examples/core/expr_problem.xtm
  • stringify    xtlang    /digego/extempore/tree/v0.8.9/examples/core/expr_problem.xtm
  • xtm_light_diffuse    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm
  • xtm_mesh_diffuse    xtlang    /digego/extempore/tree/v0.8.9/libs/external/graphics-pipeline.xtm