https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87291

--- Comment #4 from bouanto at zoho dot com ---
Oh, maybe it wasn't clear, but what I meant by constraints is: the output
operands, the input operands, and clobbers.

I guess we could make multiple parameters in the function for those.
For the things like (old) in "=r" (old), those would simply be sent as
arguments to the returned function.

So, an example like this:

```c
bool old;
__asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
         "sbb %0,%0"      // Use the CF to calculate old.
   : "=r" (old), "+rm" (*Base)
   : "Ir" (Offset)
   : "cc");
```

would be created like this:

```c
gcc_jit_field *field_old = gcc_jit_context_new_field(ctxt, NULL, bool_type,
"old");
gcc_jit_field *field_base = …
gcc_jit_field *fields[2] = {field_bool, field_base};
gcc_jit_struct *return_type = gcc_jit_context_new_struct_type (ctxt, NULL,
"return_type", 2, fields);
gcc_jit_type *param_type = …
gcc_jit_param *param = gcc_jit_context_new_param(ctxt, NULL, param_type,
"param_offset")
bool is_volatile = false;
bool align_stack = false; // Does gcc have this option?
enum gcc_jit_asm_dialect dialect = GCC_JIT_ASM_DIALECT_INTEL;
gcc_jit_function* function = gcc_jit_block_add_extended_asm(block, NULL,
return_type, 1, &param,
    "btsl %2,%1\n\t"
    "sbb %0,%0", "=r,+rm" /* for "=r" and "+rm", it's comma-separated */, "Ir",
"cc", is_volatile, align_stack, dialect);
gcc_jit_context_new_call(ctxt, function, NULL, 1, &offset_rvalue); // This
returns the struct whose type was defined earlier.
```

Reply via email to