Редактирование: Преобразования

Перейти к: навигация, поиск

Внимание! Вы не авторизовались на сайте. Ваш IP-адрес будет публично видимым, если вы будете вносить любые правки. Если вы войдёте или создадите учётную запись, правки вместо этого будут связаны с вашим именем пользователя, а также у вас появятся другие преимущества.

Правка может быть отменена. Пожалуйста, просмотрите сравнение версий, чтобы убедиться, что это именно те изменения, которые вас интересуют, и нажмите «Записать страницу», чтобы изменения вступили в силу.
Текущая версия Ваш текст
Строка 12: Строка 12:
 
  sltof -- F(ll)
 
  sltof -- F(ll)
  
Расширение точности временного действия выполняется с помощью семейства инструкций ext. Поскольку [[Простые типы данных|типы]] QBE не уточняют наличие или отсуствие знака (например, в LLVM), существуют инструкции расширения, чтобы расширять знак, и нулевое расширение значения. Например, <strong>extsb</strong> принимает в качестве аргумента w (word) и знак - расширяет 8 младших бит до полного w (word) или l (long), в зависимости от типа возвращаемого значения.
+
 
 
<pre>Extending the precision of a temporary is done using the ext family of instructions. Because QBE types do not precise the signedness (like in LLVM), extension instructions exist to sign-extend and zero-extend a value. For example, extsb takes a word argument and sign-extend the 8 least-significant bits to a full word or long, depending on the return type.</pre>
 
<pre>Extending the precision of a temporary is done using the ext family of instructions. Because QBE types do not precise the signedness (like in LLVM), extension instructions exist to sign-extend and zero-extend a value. For example, extsb takes a word argument and sign-extend the 8 least-significant bits to a full word or long, depending on the return type.</pre>
  
Инструкции <strong>exts</strong> и <strong>truncd</strong> используются для изменения точности чисел с плавающей запятой. Когда двойной аргумент <strong>truncd</strong> не может быть представлен как число с плавающей точкой с одинарной точностью, он усекается к нулю.
 
 
<pre>The instructions exts and truncd are provided to change the precision of a floating point value. When the double argument of truncd cannot be represented as a single-precision floating point, it is truncated towards zero.</pre>
 
<pre>The instructions exts and truncd are provided to change the precision of a floating point value. When the double argument of truncd cannot be represented as a single-precision floating point, it is truncated towards zero.</pre>
  
Преобразование между целыми знаковыми числами и чисел с плавающей точкой выполняется с использованием инструкции <strong>stosi</strong> (d - double в знаковое целое), <strong>dtosi</strong> (d - double в знаковое целое), <strong>swtof</strong> (знаковое целое w - word во float) и <strong>sltof</strong> (знаковое l - long во float). Эти инструкции обрабатывают только целые числа со знаком, преобразовывание в и из беззнаковых типов еще не поддерживается.
 
 
<pre>Converting between signed integers and floating points is done using stosi (single to signed integer), dtosi (double to signed integer), swtof (signed word to float), and sltof (signed long to float). These instructions only handle signed integers, conversion to and from unsigned types are not yet supported.</pre>
 
<pre>Converting between signed integers and floating points is done using stosi (single to signed integer), dtosi (double to signed integer), swtof (signed word to float), and sltof (signed long to float). These instructions only handle signed integers, conversion to and from unsigned types are not yet supported.</pre>
  
Благодаря [[Подтипы | подтипированию]] нет необходимости в реализации инструкции снижения точности временного целого числа.
 
 
<pre>Because of Subtyping, there is no need to have an instruction to lower the precision of an integer temporary.</pre>
 
<pre>Because of Subtyping, there is no need to have an instruction to lower the precision of an integer temporary.</pre>
  

Пожалуйста, учтите, что любой ваш вклад в проект «Compilers Wiki» может быть отредактирован или удалён другими участниками. Если вы не хотите, чтобы кто-либо изменял ваши тексты, не помещайте их сюда.
Вы также подтверждаете, что являетесь автором вносимых дополнений, или скопировали их из источника, допускающего свободное распространение и изменение своего содержимого (см. Compilers Wiki:Авторские права). НЕ РАЗМЕЩАЙТЕ БЕЗ РАЗРЕШЕНИЯ ОХРАНЯЕМЫЕ АВТОРСКИМ ПРАВОМ МАТЕРИАЛЫ!