Artem Pelenitsyn
Artem Pelenitsyn

Reputation: 2578

Software implementation of integer division in LLVM backend

I'm trying to implement a codegen (I seek for assembler listing only, not a binary code) for custom architecture which doesn't have hardware implementation of integer division. I use clang frontend and get symbols like __divsi3 in my assembler listing. I see an implementation of __divsi3 in compiler_rt library of LLVM. How could I use this?

Upvotes: 1

Views: 1156

Answers (1)

Richard Pennington
Richard Pennington

Reputation: 19965

You'll use your new compiler to compile the appropriate functions in compiler-rt that your processor is missing. Then include the compiler-rt library at link time so the unresolved symbol can be resolved.

__divsi3 is just a simple C function that uses simpler operations to perform the division that your architecture doesn't support.

Upvotes: 2

Related Questions