Error impossible constraint in asm

I'm starting with assembler under Linux. I have saved the following code as testasm.c and compiled it with: gcc testasm.c -otestasm The compiler replies: "impossible constraint in ‘asm’". #include...

The constraints are single letters (possibly with extra decorations), and you can specify several alternatives (i.e., an inmediate operand or register is «ir»). So the constraint «eax» means constraints «e» (signed 32-bit integer constant), «a» (register eax), or «x» (any SSE register). That is a bit different that what OP meant… and output to an «e» clearly doesn’t make any sense. Also, if some operand (in this case an input and an output) must be the same as another, you refer to it by a number constraint. There is no need to say eax will be clobbered, it is an output. You can refer to the arguments in the inline code by %0, %1, …, no need to use explicit register names. So the correct version for the code as intended by OP would be:

#include <stdio.h>

int main(void)
{
    int foo=10, bar=15;

    __asm__ __volatile__ (
        "addl %2, %0"
        : "=a" (foo)
        : "0" (foo), "b" (bar)
    );

    printf("foo = %d", foo);

    return 0;
}

A better solution would be to allow %2 to be anything, and %0 a register (as x86 allows, but you’d have to check your machine manual):

#include <stdio.h>

int main(void)
{
    int foo=10, bar=15;

    __asm__ __volatile__ (
        "addl %2, %0"
        : "=r" (foo)
        : "0" (foo), "g" (bar)
    );

    printf("foo = %d", foo);

    return 0;
}

Содержание

  1. Get a error: impossible constraint in ‘asm’? #79
  2. Comments
  3. Compilation error with 4.14 kernel: «impossible constraint in asm» #50
  4. Comments
  5. asm impossible constraint #3
  6. Comments
  7. Compilation error with g++: impossible register constraint in ‘asm’ #554
  8. Comments
  9. Building

Get a error: impossible constraint in ‘asm’? #79

I get a error: impossible constraint in ‘asm’. it looks like some asm code can’t be used in NDK(just guess)? i found that the error occur in below, Anyone has this error before?
static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
<
#ifndef _MSC_VER
uint32_t a = *eax, b, c, d;
asm volatile ( «cpuidnt» : «+a»(a), «=b»(b), «=c»(c), «=d»(d) );

*eax = a;
*ebx = b;
*ecx = c;
*edx = d;
#else
uint32_t cpuInfo[4];
__cpuid(cpuInfo, *eax);
*eax = cpuInfo[0];
*ebx = cpuInfo[1];
*ecx = cpuInfo[2];
*edx = cpuInfo[3];
#endif
>

The text was updated successfully, but these errors were encountered:

@amazingyyc There is some related discussion in issue #74. Many people have same problem as yours. You are not alone.

Hope the developers fix it asap!

I think the reason is that: a asm code «asm volatile ( «cpuidnt» : «+a»(a), «=b»(b), «=c»(c), «=d»(d) );» in file simd.h is not supported in ARM. so annotation the function(TH_API void THVector_(vectorDispatchInit)();) in file TH/generic/THVector.h and file THVectorDispatch.c. it will work well.

the above method is not fit the «torch-android». But works well in my own Android project that just include torch/TH and torch/THNN.
But I got another question: my own build project is very very slower than other ‘s. Should I set any parameter in my own building? @BrianOn99

@amazingyyc I am not an a developer here. I have never been able to run the demo app. If it is possible, would you mind share how you build the app? (Did you success?)

Nevertheless, I could give you some suggestion. Some one has integrated openblas to torch-android: #68. See if that can help you!

[Edit]
Sorry I may have misunderstood your question. Did you mean your building process is slow or your app is slow?

thank u for your apply. I do not run this demo app successfully either. I just run the only troch/TH and torch/THNN on android(the core of torch). The method has been mentioned: annotation the code «asm volatile ( «cpuidnt» : «+a»(a), «=b»(b), «=c»(c), «=d»(d) );»..
By the way thank u for your advice about the openblas.

I had a similar error. I resolved it by adding NEON_FOUND flash to true in the build script so that it builds for neon platform.
I have updated both this repo and NVIDIA location, please try the trick above.

Thanks @borisfom. May I ask could the sample apps be build and run successfully now (without CUDA)?

my app is slow compared other’s THNN.so like prisma (the prisma app using the thnn too).

update the code and the problem is gone(i do not know why)?!
But got another problem: error: ‘THHalfVector_fill_DISPATCHTABLE’ undeclared (first use in this function) #define THVector_(NAME) TH_CONCAT_4(TH,Real,Vector_,NAME)
I feel the world is going to dark 😩

@amazingyyc Yeah, I have already opened the issue #78.
The «HalfVector» stuff are added for the CUDA backend, but it should be optional.

Источник

Compilation error with 4.14 kernel: «impossible constraint in asm» #50

Trying to compile the latest isgx module from the master branch:

I see this error on both Fedora 27 and Arch Linux.

The text was updated successfully, but these errors were encountered:

This seems to be a recurrence of #13, and even has the same workaround.

So I understand that the only difference is the addition of M=$(PWD) instead of SUBDIRS=$(PWD) in the original Makefile.
Can we close it?

I have been working around this problem by removing the -O0 option from CFLAGS_MODULE in the Makefile . I would consider closing it without an attempt at understanding it to be premature.

I ran into similiar problems when compiling kernel 4.14 by changing -O2 to -O0.

`In file included from ./include/linux/compiler_types.h:58:0,
from ./include/linux/compiler.h:5,
from ./arch/x86/include/asm/atomic.h:5,
from ./include/linux/atomic.h:5,
from ./include/linux/crypto.h:20,
from arch/x86/kernel/asm-offsets.c:9:
./arch/x86/include/asm/cpufeature.h: In function ‘_static_cpu_has’:
./include/linux/compiler-gcc.h:270:38: warning: asm operand 0 probably doesn’t match constraints
#define asm_volatile_goto(x. ) do < asm goto(x); asm («»); >while (0)
^
./arch/x86/include/asm/cpufeature.h:148:3: note: in expansion of macro ‘asm_volatile_goto’
asm_volatile_goto(«1: jmp 6fn»
^
./include/linux/compiler-gcc.h:270:38: warning: asm operand 2 probably doesn’t match constraints
#define asm_volatile_goto(x. ) do < asm goto(x); asm («»); >while (0)
^
./arch/x86/include/asm/cpufeature.h:148:3: note: in expansion of macro ‘asm_volatile_goto’
asm_volatile_goto(«1: jmp 6fn»

./include/linux/compiler-gcc.h:270:38: error: impossible constraint in ‘asm’
#define asm_volatile_goto(x. ) do < asm goto(x); asm («»); >while (0)
^
./arch/x86/include/asm/cpufeature.h:148:3: note: in expansion of macro ‘asm_volatile_goto’
asm_volatile_goto(«1: jmp 6fn»
^`

The trouble above was caused by extended assembly in arch/x86/include/asm/cpufeature.h, where the modifiers of the operand 0 and 2 were i, meaning that immediate integers were expected. But they both used parameter bit, which was a variable instead of a constant. If -O2 was specified, the inline function _static_cpu_has was expanded with a constant in place of parameter bit, which bypassed the restriction.

static __always_inline __pure bool _static_cpu_has(u16 bit) < asm_volatile_goto(«1: jmp 6fn» «2:n» «.skip -(((5f-4f) — (2b-1b)) >0) * » «((5f-4f) — (2b-1b)),0x90n» «3:n» «.section .altinstructions,»a»n» » .long 1b — .n» /* src offset */ » .long 4f — .n» /* repl offset */ » .word %P1n» /* always replace */ » .byte 3b — 1bn» /* src len */ » .byte 5f — 4fn» /* repl len */ » .byte 3b — 2bn» /* pad len */ «.previousn» «.section .altinstr_replacement,»ax»n» «4: jmp %l[t_no]n» «5:n» «.previousn» «.section .altinstructions,»a»n» » .long 1b — .n» /* src offset */ » .long 0n» /* no replacement */ » .word %P0n» /* feature bit */ » .byte 3b — 1bn» /* src len */ » .byte 0n» /* repl len */ » .byte 0n» /* pad len */ «.previousn» «.section .altinstr_aux,»ax»n» «6:n» » testb %[bitnum],%[cap_byte]n» » jnz %l[t_yes]n» » jmp %l[t_no]n» «.previousn» : : **»i» (bit)**, «i» (X86_FEATURE_ALWAYS), **[bitnum] «i» (1 > 3]) : : t_yes, t_no); t_yes: return true; t_no: return false; >

Источник

asm impossible constraint #3

I get the following error, while running:

$ make
.
make[4]: Entering directory ‘/home/july/msed/syslinux/gpxe/src’ [BUILD] bin/int13.o arch/i386/interface/pcbios/int13.c: In function ‘register_int13_drive’: arch/i386/interface/pcbios/int13.c:469:2: warning: asm operand 0 probably doesn’t match constraints __asm__ __volatile__ ( ^ arch/i386/interface/pcbios/int13.c:469:2: error: impossible constraint in ‘asm’ bin/deps/arch/i386/interface/pcbios/int13.c.d:86: recipe for target ‘bin/int13.o’ failed make[4]: *** [bin/int13.o] Error 1

My build env is:
$ nasm -v
NASM version 2.11.08 compiled on Mar 24 2015

$ gcc -v
Using built-in specs.

Configured with: /build/gcc-multilib/src/gcc-5.3.0/configure —prefix=/usr —libdir=/usr/lib —libexecdir=/usr/lib —mandir=/usr/share/man —infodir=/usr/share/info —with-bugurl=https://bugs.archlinux.org/ —enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ —enable-shared —enable-threads=posix —enable-libmpx —with-system-zlib —with-isl —enable-__cxa_atexit —disable-libunwind-exceptions —enable-clocale=gnu —disable-libstdcxx-pch —disable-libssp —enable-gnu-unique-object —enable-linker-build-id —enable-lto —enable-plugin —enable-install-libiberty —with-linker-hash-style=gnu —enable-gnu-indirect-function —enable-multilib —disable-werror —enable-checking=release

Thread model: posix

gcc version 5.3.0 (GCC)

Built for x86_64-unknown-linux-gnu

Linux stoffle 4.3.3-3-ARCH #1 SMP PREEMPT Wed Jan 20 08:12:23 CET 2016 x86_64 GNU/Linux

I’m running Arch Linux, so all the tools are the latest versions of respective tools.

I’m not an expert of asm constraints, but I did a couple of changes in order to complete the make process (see the patch file). I assume, those changes might be wrong (EDIT: are wrong — see my next comment).
asm_constraints.patch.zip

The text was updated successfully, but these errors were encountered:

Источник

Compilation error with g++: impossible register constraint in ‘asm’ #554

Hello, I’m experiencing a compilation error with master, commit 1a7f19c.

I’ve tried dropping to -O2 as suggested in #553 but it does not fix the error.

I just compiled with make and the compilation aborted in gcm-simd.cpp . Here is the error

I’m running Red-Hat 6.7 and the compilers I have are

The text was updated successfully, but these errors were encountered:

Thanks @EduardoMiravalls . And sorry about things.

error: impossible register constraint in ‘asm’

Yeah, I’ve seen that before. Here’s the ASM, and there’s not much to it. Below is from gcm-simd.cpp :

The constraint it is talking about is the part : «=m» (a[0]) : «xm»(b[0]), «xm»(c[0])); . The x is a SSE register, and the m is memory. I wonder if two memory expressions is giving the older tool chain problems. Or maybe, the toolchain wants the output constraint to be xm .

Give me some time to find a machine with GCC 4.4. I think I have one somewhere.

I believe CentOS 5 comes with g++ 4.4.7, maybe you can use it in a vm?

OK, going back to Wei’s code before we started fiddling with things:

I was able to duplicate it with CentOS 5 (Binutils 2.17). This clears the issue under CentOS:

I’m going to check-in the one shown above with output operand of xm . The GCC folks tell us to provide GCC with as many alternatives as possible, so we are consistent with their best practices. But keep in mind that’s what got us into trouble in the first place — we added additional constraints to give the inline assembler a more choices 😮

Ugh, this broke GCC 4.8/4.9 on Core2’s:

Mind if I ask why did it specifically affect Core2s?
FYI, I’ve just pulled your latest commits and it compiles OK on my setup.

Mind if I ask why did it specifically affect Core2s?

The Core2 machine is what I have for testing on real hardware. The issue probably affects other machines, too. It is likely tied to a few versions of Binutils, which supplies the assembler.

I also have older machines that predate the Core2. They include PIII’s and P4’s. They probably suffer it too when the assembler version is just right. I test less frequently on them because they are slow.

Источник

Building

syslinux-6.04_pre1 fails to build on gcc-10 due to -fno-common change; gcc-10 (and above) flipped a default, from -fcommon to -fno-common.

gcc-10 will reject multiple definitions of global variables. Possible/potential workaround: add/append -fcommon to CFLAGS. Ideally, the code would need a few ‘extern‘ additions and maybe moving variable definitions.

  • undefined reference to `strlen’ . Possibly related to (the link to) libc and/or to GCC-10+ optimizer. Solution: provide missing strlen() implementation in dos/string.h .
  • Prevent-pow-optimization when using gcc 8.2+.
  • internal error — lzo_init() failed! (inconsistent/sporadic error).

    Syslinux fails to build due to aliasing bugs in lzo. Add -fno-strict-aliasing to lzo/Makefile .

    Fix broken efi binaries with binutils 2.31+.

    «Binutils >= 2.31 writes two PT_LOAD segments by default. This is not supported by the wrapper.c script used to convert the shared object into an elf binary.»

    Note: 6.04-pre1+ should not be affected by this issue.

  • When building with glibc 2.23+, the «major», «minor» and «makedev» functions are defined in «sys/sysmacros.h» . The patch «extlinux: pull in sys/sysmacros.h for major/minor/makedev», applied to Syslinux during 2016Apr, should help. Please note that not only Syslinux is affected by this change in glibc.
  • Patches already included in Syslinux 6.04-pre1 (released 2016Mar):

    Testing Syslinux 6.04-pre1 (or later) is recommended.

    Источник

    I ran into similiar problems when compiling kernel 4.14 by changing -O2 to -O0.

    `In file included from ./include/linux/compiler_types.h:58:0,
    from ./include/linux/compiler.h:5,
    from ./arch/x86/include/asm/atomic.h:5,
    from ./include/linux/atomic.h:5,
    from ./include/linux/crypto.h:20,
    from arch/x86/kernel/asm-offsets.c:9:
    ./arch/x86/include/asm/cpufeature.h: In function ‘_static_cpu_has’:
    ./include/linux/compiler-gcc.h:270:38: warning: asm operand 0 probably doesn’t match constraints
    #define asm_volatile_goto(x…) do { asm goto(x); asm («»); } while (0)
    ^
    ./arch/x86/include/asm/cpufeature.h:148:3: note: in expansion of macro ‘asm_volatile_goto’
    asm_volatile_goto(«1: jmp 6fn»
    ^
    ./include/linux/compiler-gcc.h:270:38: warning: asm operand 2 probably doesn’t match constraints
    #define asm_volatile_goto(x…) do { asm goto(x); asm («»); } while (0)
    ^
    ./arch/x86/include/asm/cpufeature.h:148:3: note: in expansion of macro ‘asm_volatile_goto’
    asm_volatile_goto(«1: jmp 6fn»

    ./include/linux/compiler-gcc.h:270:38: error: impossible constraint in ‘asm’
    #define asm_volatile_goto(x…) do { asm goto(x); asm («»); } while (0)
    ^
    ./arch/x86/include/asm/cpufeature.h:148:3: note: in expansion of macro ‘asm_volatile_goto’
    asm_volatile_goto(«1: jmp 6fn»
    ^`

    The trouble above was caused by extended assembly in arch/x86/include/asm/cpufeature.h, where the modifiers of the operand 0 and 2 were i, meaning that immediate integers were expected. But they both used parameter bit, which was a variable instead of a constant. If -O2 was specified, the inline function _static_cpu_has was expanded with a constant in place of parameter bit, which bypassed the restriction.

    static __always_inline __pure bool _static_cpu_has(u16 bit) { asm_volatile_goto("1: jmp 6fn" "2:n" ".skip -(((5f-4f) - (2b-1b)) > 0) * " "((5f-4f) - (2b-1b)),0x90n" "3:n" ".section .altinstructions,"a"n" " .long 1b - .n" /* src offset */ " .long 4f - .n" /* repl offset */ " .word %P1n" /* always replace */ " .byte 3b - 1bn" /* src len */ " .byte 5f - 4fn" /* repl len */ " .byte 3b - 2bn" /* pad len */ ".previousn" ".section .altinstr_replacement,"ax"n" "4: jmp %l[t_no]n" "5:n" ".previousn" ".section .altinstructions,"a"n" " .long 1b - .n" /* src offset */ " .long 0n" /* no replacement */ " .word %P0n" /* feature bit */ " .byte 3b - 1bn" /* src len */ " .byte 0n" /* repl len */ " .byte 0n" /* pad len */ ".previousn" ".section .altinstr_aux,"ax"n" "6:n" " testb %[bitnum],%[cap_byte]n" " jnz %l[t_yes]n" " jmp %l[t_no]n" ".previousn" : : **"i" (bit)**, "i" (X86_FEATURE_ALWAYS), **[bitnum] "i" (1 << (bit & 7)),** [cap_byte] "m" (((const char *)boot_cpu_data.x86_capability)[bit >> 3]) : : t_yes, t_no); t_yes: return true; t_no: return false; }

    Click here follow the steps to fix Mips Error Impossible Constraint In ‘asm’ and related errors.

    Instructions

     

    To Fix (Mips Error Impossible Constraint In ‘asm’) error you need to
    follow the steps below:

    Step 1:

     
    Download
    (Mips Error Impossible Constraint In ‘asm’) Repair Tool
       

    Step 2:

     
    Click the «Scan» button
       

    Step 3:

     
    Click ‘Fix All‘ and you’re done!
     

    Compatibility:
    Windows 7, 8, Vista, XP

    Download Size: 6MB
    Requirements: 300 MHz Processor, 256 MB Ram, 22 MB HDD

    Limitations:
    This download is a free evaluation version. To unlock all features and tools, a purchase is required.

    Mips Error Impossible Constraint In ‘asm’ Error Codes are caused in one way or another by misconfigured system files
    in your windows operating system.

    If you have Mips Error Impossible Constraint In ‘asm’ errors then we strongly recommend that you

    Download (Mips Error Impossible Constraint In ‘asm’) Repair Tool.

    This article contains information that shows you how to fix
    Mips Error Impossible Constraint In ‘asm’
    both
    (manually) and (automatically) , In addition, this article will help you troubleshoot some common error messages related to Mips Error Impossible Constraint In ‘asm’ error code that you may receive.

    Note:
    This article was updated on 2023-02-03 and previously published under WIKI_Q210794

    Contents

    •   1. What is Mips Error Impossible Constraint In ‘asm’ error?
    •   2. What causes Mips Error Impossible Constraint In ‘asm’ error?
    •   3. How to easily fix Mips Error Impossible Constraint In ‘asm’ errors

    What is Mips Error Impossible Constraint In ‘asm’ error?

    The Mips Error Impossible Constraint In ‘asm’ error is the Hexadecimal format of the error caused. This is common error code format used by windows and other windows compatible software and driver vendors.

    This code is used by the vendor to identify the error caused. This Mips Error Impossible Constraint In ‘asm’ error code has a numeric error number and a technical description. In some cases the error may have more parameters in Mips Error Impossible Constraint In ‘asm’ format .This additional hexadecimal code are the address of the memory locations where the instruction(s) was loaded at the time of the error.

    What causes Mips Error Impossible Constraint In ‘asm’ error?

    The Mips Error Impossible Constraint In ‘asm’ error may be caused by windows system files damage. The corrupted system files entries can be a real threat to the well being of your computer.

    There can be many events which may have resulted in the system files errors. An incomplete installation, an incomplete uninstall, improper deletion of applications or hardware. It can also be caused if your computer is recovered from a virus or adware/spyware
    attack or by an improper shutdown of the computer. All the above actives
    may result in the deletion or corruption of the entries in the windows
    system files. This corrupted system file will lead to the missing and wrongly
    linked information and files needed for the proper working of the
    application.

    How to easily fix Mips Error Impossible Constraint In ‘asm’ error?

    There are two (2) ways to fix Mips Error Impossible Constraint In ‘asm’ Error:

    Advanced Computer User Solution (manual update):

    1) Start your computer and log on as an administrator.

    2) Click the Start button then select All Programs, Accessories, System Tools, and then click System Restore.

    3) In the new window, select «Restore my computer to an earlier time» option and then click Next.

    4) Select the most recent system restore point from the «On this list, click a restore point» list, and then click Next.

    5) Click Next on the confirmation window.

    6) Restarts the computer when the restoration is finished.

    Novice Computer User Solution (completely automated):

    1) Download (Mips Error Impossible Constraint In ‘asm’) repair utility.

    2) Install program and click Scan button.

    3) Click the Fix Errors button when scan is completed.

    4) Restart your computer.

    How does it work?

    This tool will scan and diagnose, then repairs, your PC with patent
    pending technology that fix your windows operating system registry
    structure.
    basic features: (repairs system freezing and rebooting issues , start-up customization , browser helper object management , program removal management , live updates , windows structure repair.)

    У меня странный. Я работаю над встроенной системой, используя файлы заголовков поставщиков. Я компилирую файлы, используя GCC 4.6.3. Я хочу использовать C ++ для своего кода, у меня есть ошибка, которую я не могу понять. Я запускаю пример программы поставщика, и все, что я сделал, это изменил имя файла main.c на main.cpp. В результате, я предполагаю, что заголовочные файлы интерпретируются компилятором C ++. Одна из них содержит следующие строки:

    __attribute__((naked)) static return_type signature 
    { 
    __asm( 
    "svc %0n" 
    "bx r14" : : "I" (number) : "r0" 
    ); 
    }
    

    Файлы компилируются должным образом, если имя файла main.c, я предполагаю, что это потому, что файл обрабатывается компилятором C. Я получаю ошибку, если использую C ++,

    error: impossible constraint in 'asm'
    

    Но опять же, у меня нет проблем с компилятором C. Мне нужно вызвать функции, которые используют это определение в файлах C ++. Я рассмотрел написание функций-оболочек, которые остаются на стороне c, и ссылки на них, но это было бы настоящей болью и менее эффективным. Какие-либо предложения?

    4

    Решение

    svc также известен как swi это ARM / Thumb программное прерывание инструкция. Требуются только константы, но они отличаются от других констант регистров. То есть, mov r0, #4096, Вам нужно использовать препроцессор и вставку токена, если вы хотите указать немедленное. number не может быть переменная или же регистр.

    #define syscall(number) __attribute__((naked)) static return_type signature 
    { 
    __asm( 
    "svc " #number "n" 
    "bx r14" : : : "r0" 
    ); 
    }
    

    буду работать. Замечания: # это ‘C’ препроцессоры преобразуются. Также обратите внимание, что неэффективно смотреть на SVC номер, как это в I-CACHE и проверка требует D-CACHE, Как правило, это всегда constant и функция номер передается в регистр для более быстрых системных вызовов.

    Руководство GCC говорит,

    ‘Я’— Целое число, допустимое в качестве непосредственного операнда в данных
    инструкция по обработке. То есть целое число в диапазоне 0
    до 255 повернуты кратно 2

    Это типично для Операнды обработки данных — немедленные, раздел A5.1.3 ARM ARM. SVC операнды либо фиксированные 8-битные в режиме большого пальца, либо фиксированные 24-битные в режиме ARM. Это может быть возможно с некоторым другим ограничением, о котором я не знаю, но, по крайней мере, строковое преобразование препроцессора будет работать, пока числовая константа передается макросу.

    Я думаю, повезло, что это сработало gcc и не повезло, что g++ не. Вы можете получить дальнейшее понимание, используя -S и просматривая (и публикуя) вывод, используя оба инструмента.

    Редактировать: Ваш код, кажется, работает с gcc-4.7.2, но number это const int местный в моем случае, использование number возможно проблема. Возможно, у него есть тонкое семантическое изменение с «C» на «C ++».

    1

    Другие решения

    Проверить Руководство GCC (встроенный ассемблер) для точного значения ограничений для вашей машины. Старые версии GCC были заведомо неаккуратными в проверке ограничений, возможно, вас это укусило. Странно что gcc а также g++ (та же версия?) обрабатывать код по-разному, это просто может быть быть ошибкой компилятора, но я бы посчитал это только после того, как все остальные объяснения были исчерпаны.

    0

    erupter

    Senior Member

    • Total Posts : 179
    • Reward points : 0
    • Joined: 2011/05/31 15:15:52
    • Location: Rome, Italy
    • Status: offline

    return frac ? mad_f_mul(requantized, root_table[3 + frac]) : requantized;

    On www.mypic32.com you can find the whole source code of the multi-stack FreeRTOS demo you can see at work here.
    I’ve been unable to compile due to the above reported line.
    I have a MultimediaExpansionBoard and a PIC32 ESK.
    The necessary changes (that I could find) have been made to the HardwareProfile.
    But the mp3 codec is out of my reach. What does that error mean?

    ivan braga

    New Member

    • Total Posts : 28
    • Reward points : 0
    • Joined: 2010/06/01 13:42:19
    • Location: The World..
    • Status: offline

    Re:error: impossible constraint in ‘asm’ ?????????


    2011/10/02 23:37:42

    (permalink)

    There is no way to peace, peace is the way …. (Mahatma Gandhi)

    erupter

    Senior Member

    • Total Posts : 179
    • Reward points : 0
    • Joined: 2011/05/31 15:15:52
    • Location: Rome, Italy
    • Status: offline

    Re:error: impossible constraint in ‘asm’ ?????????


    2011/10/03 06:13:35

    (permalink)

    No it does not.
    The error says it’s asm, but in asm the instruction would be an SLT from what I read. But there is no SLT, so what’s this?
    It’s C so it says
    if (frac) then mad_f_mul(requantized, root_table[3 + frac]) else requantized
    Then how is the asm unable to fulfill a restraint? what restraint? what should I look for? I don’t know asm, I wouldn’t see the error… and since it doesn’t build, how can I see the asm anyway?

    ivan braga

    New Member

    • Total Posts : 28
    • Reward points : 0
    • Joined: 2010/06/01 13:42:19
    • Location: The World..
    • Status: offline

    Re:error: impossible constraint in ‘asm’ ?????????


    2011/10/03 06:51:13

    (permalink)

    Sorry my friend, but in ASM can not help you. See also a message that I have a problem with ASM. The complile can not interpret an implicit denial that I put in a «IF_ELSE_IF.»
    Let’s wait for someone who can help us.

    Ivan

    There is no way to peace, peace is the way …. (Mahatma Gandhi)

    BitWise

    Super Member

    • Total Posts : 1238
    • Reward points : 0
    • Joined: 2004/11/09 13:24:20
    • Location: UK
    • Status: offline

    Re:error: impossible constraint in ‘asm’ ?????????


    2011/10/03 11:39:44

    (permalink)

    I suspect that mad_f_mul is a macro that expands into an assembler instruction and it can’t cope with ‘root_table[3 + frac]’ as a parameter.

    I would try introducing a temporary variable :

    SomeAppropriateType temp = root_table[3 + frac];
    return frac ? mad_f_mul(requantized, temp) : requantized;

    Look at the definition of root_table to figure out the type for the temporary variable

    Throughout your life advance daily, becoming more skillful than yesterday, more skillful than today. This is never-ending.

    Yamamoto Tsunetomo (1659-1719)

    Модератор: Модераторы разделов

    IMB

    Сообщения: 2555
    ОС: Debian

    asm: impossible constraint in ‘asm’

    Доброго дня!
    Пробую собрать protobuf для архитектуры SH4, сборка останавливается с сообщенеи о некорректности asm — google/protobuf/stubs/atomicops_internals_mips_gcc.h:69: error: impossible constraint in ‘asm’

    Код: Выделить всё

    inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
                                             Atomic32 old_value,
                                             Atomic32 new_value) {
      Atomic32 prev, tmp;
      __asm__ __volatile__(".set pushn"
                           ".set noreordern"
                           "1:n"
                           "ll %0, %5n"  // prev = *ptr
                           "bne %0, %3, 2fn"  // if (prev != old_value) goto 2
                           "move %2, %4n"  // tmp = new_value
                           "sc %2, %1n"  // *ptr = tmp (with atomic check)
                           "beqz %2, 1bn"  // start again on atomic error
                           "nopn"  // delay slot nop
                           "2:n"
                           ".set popn"
                           : "=&r" (prev), "=m" (*ptr), "=&r" (tmp)
                           : "Ir" (old_value), "r" (new_value), "m" (*ptr)
                           : "memory"); // 69 строка
      return prev;
    }

    С asm мне как-то не приходилось сталкиваться, можете подсказать решение?
    Спасибо.

    IMB

    Сообщения: 2555
    ОС: Debian

    Re: asm: impossible constraint in ‘asm’

    Сообщение

    IMB » 15.07.2016 10:08

    google/protobuf/stubs/atomicops_internals_mips_gcc.h:69: error: unknown register name ‘m’ in ‘asm’

    Возможно важно, что используется достаточно старый gcc, но это к сожалению без вариантов:

    Код: Выделить всё

    # sh4-linux-g++ --version
    sh4-linux-g++ (GCC) 4.2.4 (snapshot) (STMicroelectronics/Linux Base 4.2.4-52)

    Аватара пользователя

    Bizdelnick

    Модератор
    Сообщения: 19825
    Статус: nulla salus bello
    ОС: Debian GNU/Linux

    Re: asm: impossible constraint in ‘asm’

    Сообщение

    Bizdelnick » 15.07.2016 10:43

    IMB писал(а): ↑

    15.07.2016 10:08

    используется достаточно старый gcc, но это к сожалению без вариантов

    Почему?

    Shell

    % aptitude show c++-compiler-sh4-linux-gnu
    Нет в наличии или подходящей версии для c++-compiler-sh4-linux-gnu
    Пакет: c++-compiler-sh4-linux-gnu
    Состояние: не реальный пакет
    Предоставляется: g++-4.3-sh4-linux-gnu, g++-4.4-sh4-linux-gnu, g++-4.5-sh4-linux-gnu, g++-4.6-sh4-linux-gnu,
    g++-4.7-sh4-linux-gnu
    %

    Пишите правильно:

    в консоли
    вку́пе (с чем-либо)
    в общем
    вообще
    в течение (часа)
    новичок
    нюанс
    по умолчанию
    приемлемо
    проблема
    пробовать
    трафик

    Аватара пользователя

    serzh-z

    Бывший модератор
    Сообщения: 8256
    Статус: Маньяк
    ОС: Arch, Fedora, Ubuntu
    Контактная информация:

    Re: asm: impossible constraint in ‘asm’

    Сообщение

    serzh-z » 15.07.2016 13:12

    IMB
    Теоретически, можно вообще убрать «memory» из clobber-списка, так как prev, *ptr, tmp, old_value, new_value уже перечислены выше, а никакая другая память инструкциями выше не затрагивается.

    Понравилась статья? Поделить с друзьями:
  • Error importing hplip modules is hplip installed
  • Error implicit declaration of function itoa
  • Error implicit declaration of function getline
  • Error imei huawei e1550
  • Error image type not supported