;;;; predicate VOPs for the LoongArch VM

;;;; This software is part of the SBCL system. See the README file for
;;;; more information.
;;;;
;;;; This software is derived from the CMU CL system, which was
;;;; written at Carnegie Mellon University and released into the
;;;; public domain. The software is in the public domain and is
;;;; provided with absolutely no warranty. See the COPYING and CREDITS
;;;; files for more information.

(in-package "SB-VM")

;;;; The Branch VOP.

;;; The unconditional branch, emitted when we can't drop through to the desired
;;; destination.  Dest is the continuation we transfer control to.
(define-vop (branch)
  (:info dest)
  (:generator 3
    (inst j dest)))

;;;; Generic conditional VOPs

;;; The generic conditional branch, emitted immediately after test
;;; VOPs that only set flags.
(define-vop (branch-if)
  (:info dest flags not-p)
  (:ignore dest not-p flags)
  (:generator 0
    (error "BRANCH-IF should not be needed on LA.")))

(defun convert-conditional-move-p (dst-tn)
  (declare (ignore dst-tn))
  nil)

;;;; Conditional VOPs:
(define-vop (if-eq)
  (:args (x :scs (any-reg descriptor-reg zero))
         (y :scs (any-reg descriptor-reg zero)))
  (:conditional)
  (:info target not-p)
  (:policy :fast-safe)
  (:translate eq)
  (:generator 3
    (if not-p
        (inst bne x y target)
        (inst beq x y target))))
