Function: c-lineup-gcc-asm-reg
c-lineup-gcc-asm-reg is a byte-compiled function defined in
cc-align.el.gz.
Signature
(c-lineup-gcc-asm-reg ELEM)
Documentation
Line up a gcc asm register under one on a previous line.
asm ("foo %1, %0\\n"
"bar %0, %1"
: "=r" (w),
"=r" (x)
: "0" (y),
"1" (z));
The "x" line is aligned to the text after the ":" on the "w" line, and similarly "z" under "y".
This is done only in an "asm" or "__asm__" block, and only to those lines mentioned. Anywhere else nil is returned. The usual arrangement is to have this routine as an extra feature at the start of arglist line-ups, e.g.
(c-lineup-gcc-asm-reg c-lineup-arglist)
Works with: arglist-cont, arglist-cont-nonempty.
Probably introduced at or before Emacs version 22.1.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-align.el.gz
;; Contributed by Kevin Ryde <user42@zip.com.au>.
(defun c-lineup-gcc-asm-reg (elem)
"Line up a gcc asm register under one on a previous line.
asm (\"foo %1, %0\\n\"
\"bar %0, %1\"
: \"=r\" (w),
\"=r\" (x)
: \"0\" (y),
\"1\" (z));
The \"x\" line is aligned to the text after the \":\" on the \"w\" line, and
similarly \"z\" under \"y\".
This is done only in an \"asm\" or \"__asm__\" block, and only to
those lines mentioned. Anywhere else nil is returned. The usual
arrangement is to have this routine as an extra feature at the start
of arglist line-ups, e.g.
(c-lineup-gcc-asm-reg c-lineup-arglist)
Works with: arglist-cont, arglist-cont-nonempty."
(let ((orig-pos (point))
alignto)
(save-excursion
(beginning-of-line)
(and
c-opt-asm-stmt-key
;; Don't do anything if the innermost open paren isn't our one.
;; This can occur for arglist-cont-nonempty with nested arglist
;; starts on the same line.
(or (not (eq (car elem) 'arglist-cont-nonempty))
(eq (c-langelem-2nd-pos c-syntactic-element)
(c-most-enclosing-brace (c-parse-state))))
;; Find the ":" to align to. Look for this first so as to quickly
;; eliminate pretty much all cases which are not for us.
(re-search-backward "^[ \t]*:[ \t]*\\(.\\)?" (cdr elem) t)
;; Must have something after the ":".
(setq alignto (match-beginning 1))
;; Don't touch ":" lines themselves.
(progn (goto-char orig-pos)
(beginning-of-line)
(not (looking-at "^[ \t]*:")))
;; Only operate in an asm statement.
(progn (goto-char orig-pos)
(c-in-gcc-asm-p))
(vector (progn (goto-char alignto) (current-column)))))))